Subject: [xsl] xpath expression validity? From: bibhaker.saran@xxxxxxxxxx Date: Wed, 30 Oct 2002 12:52:42 +1100 |
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) < 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Sorry about the wrong sub, Mulberry Technologie | Thread | [xsl] complicacy of sorting, Evgenia Firsova |
RE: [xsl] handling failed document(, Jeff Barrett | Date | RE: [xsl] Role of XSLT?, Gregory Murphy |
Month |