Subject: Re: [xsl] Using one nodeset to dictate the format of data from another nodeset From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 7 Jun 2007 00:57:49 +0100 |
your posted input isn't well formed, but fixing that I think you just want something like the code below A note on terminology though > I have two nodesets in a single XML document. you're using xslt2 so it doesn't have a node set type, having been replaced by sequence. In a given document (in Xpath 1) there are always 2 to the n node sets, where n is the number of nodes, so always at least 4, (as there are always at least 2 nodes in a well formed document) In XPath2 of course there are infinitely many possible node sequences. You meant (I assume from the example) there were two parts of the document of interest, or perhaps you meant there were two input documents, I assumed the former and added a container element <x> to your posted input. > I would also like to be able to set the header levels within my > content based on the depth of the content element. Is it possible to > "feed" a template data from the template that called it? Yes, template parameters do exactly that, but perhaps you just want count(ancestor::*) , I'm not sure. David <x> <source-data> <content id="id1">content-1</content> <content id="id2">content-2</content> </source-data> <structure-data> <topic-ref idref="id1" > <topic-ref idref="id2" /> </topic-ref> </structure-data> </x> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:strip-space elements="*"/> <xsl:template match="/"> <html> <head> </head> <body> <xsl:apply-templates select="x/structure-data"/> </body> </html> </xsl:template> <xsl:template match="topic-ref"> <div> <xsl:value-of select="key('c',@idref)"/> <xsl:apply-templates/> </div> </xsl:template> <xsl:key name="c" match="content" use="@id"/> </xsl:stylesheet> $ saxon8 j.xml j.xsl <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <div>content-1 <div>content-2</div> </div> </body> </html> ________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom. This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Using one nodeset to dictate , Rebecca O'Connell | Thread | RE: [xsl] Using one nodeset to dict, Michael Kay |
[xsl] Using one nodeset to dictate , Rebecca O'Connell | Date | RE: [xsl] following-sibling problem, Vasu Chakkera |
Month |