[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xpath expression validity?

Subject: xpath expression validity?
From: bibhaker.saran@xxxxxxxxxx
Date: Wed, 30 Oct 2002 12:52:42 +1100
xslt param xpath expression
Hi,
 I have tried to use the modified version "gatherSchema" XSLT that runs
through the xsd files, collecting list of includes (no  imports) and then
provide some output from the collected node-sets.
Using XMLSpy v5, I can execute the following stylesheet.

The problem I am facing is although the XSLT debugger allows me to watch
the XPath expression $includes/xsd:schema/xsd:include/@schemaLocation, if
the resulting nodeset count is 0 or empty, the XSLT processor throws error
"invalid XPath expression" (2nd time around).

Unless I can use this XPath the recursion cannot be terminated.

Please explain, what went wrong in my stylesheet?

The stylesheet valid for any xsd schemas with includes is as follows:
==================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:fo="
http://www.w3.org/1999/XSL/Format" xmlns:xsd="
http://www.w3.org/2001/XMLSchema">
  <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
  <xsl:template match="/">
    <xsl:variable name="includes" select="/"/>
    <xsl:call-template name="gatherSchema">
      <!-- ... and any *new* includes in the $include parameter -->
      <xsl:with-param name="includes" select="."/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="gatherSchema">
    <xsl:param name="schemas"/>
    <xsl:param name="includes"/>
    <xsl:choose>
      <xsl:when test="count($schemas) &lt; count($schemas | $includes)">
        <!-- when $includes includes something new, recurse ... -->
        <xsl:call-template name="gatherSchema">
           <!-- ... with current $includes added to the $schemas
parameter... -->
           <xsl:with-param name="schemas" select="$schemas | $includes"/>
           <!-- ... and any *new* includes in the $include parameter -->
==>          <xsl:with-param name="includes" select="document
($includes/xsd:schema/xsd:include/@schemaLocation)"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <!-- do something with the "$schemas" nodeset containing the root
nodes of all included schemas -->
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>
==================
Bibhakar Saran
_________________________
B2B Technical Architect
TXU IT Architecture & Planning
Level 15 452 Flinders St, Melbourne
Phone : (+61 3) 9229 6151
Mobile: 0411 203036
Email: bibhaker.saran@xxxxxxxxxx



**********************************************************************************************
This email and any files transmitted with it may be confidential and are intended
solely for the use of the individual or entity to whom they are addressed. Any
confidentiality is not waived or lost because this email has been sent to you by
mistake. This email may contain personal information of individuals, and be 
subject to Commonwealth and/or State privacy laws in Australia. This email
is also subject to copyright. If you are not the intended recipient, you must not
 read, print, store, copy, forward  or use this email for any reason, in accordance
 with privacy and copyright laws. If you have received this email in error, please
notify the sender by return email, and delete this email from your inbox.
************************************************************************************TXUAU


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.