[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] how to use XSLT 1.0 with XSD substitution groups
Subject: [xsl] how to use XSLT 1.0 with XSD substitution groups From: ga11@xxxxxxxxxxxxxxxx Date: Sat, 16 Aug 2003 17:27:22 +1200 (NZST) |
Hi all -- I am writing a set of stylesheets whose input document format is defined in an XML schema (Z.xsd). The schema makes heavy use of substitution groups, which have up to 32 members. In several cases I use a template that will select all children of the current node, provided they are in a given substitution group. I have read in the archives that XSLT 2.0 will provide native support for XSD substitution groups, but is there a good way to emulate s. groups with XSLT 1.0? I do not intend to have my stylesheets read the schema in order to find out which substitution groups exist. I have manually gone through the schema and copied the names of the groups and their members. I want to hardcode this information into the stylesheet so I can "mimic" the substitution groups as they occur in the schema. Here is what I have come up with so far. The approach has several shortcomings that I can see and will list below; suggestions on how to make the code more elegant are very welcome: <!-- begin XSLT sample code --> <!-- Expression Substitution Group (esg) --> <!-- A list of all elements belonging to the Z Schema's 'Expr' substitution group --> <xsl:variable name="esg"> <Z:RefExpr/> <Z:NumExpr/> <Z:PowerExpr/> </xsl:variable> <xsl:variable name='psgns' select="xalan:nodeset($esg)"/> <!-- Selects all those children for processing that are in the XSD substitution group 'Expr' --> <xsl:template match="Z:SchText" mode="Declarations"> <xsl:for-each select="child::*"> <xsl:apply-templates select="self::node()[local-name() = local-name($esgns/*)]"/> </xsl:for-each> </xsl:template> <!-- End XSLT example code --> This approach will indeed match the nodes I intend to match. However: - Matching nodes will not be processed in the same order as they occur in the current node list - in order to say "<xsl:apply-templates select="Substitution Group Expr"/> I need three lines, but I would like to express this in a single line Any help would be much appreciated! cheers, Gerret XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] include problem - solutio, Kevin Waterson | Thread | Re: [xsl] document() function can't, Brook Ellingwood |
RE: [xsl] include problem, Lars Huttar | Date | Re: [xsl] document() function can't, Brook Ellingwood |
Month |
Keywords