[Home] [By Thread] [By Date] [Recent Entries]
On 7/19/06, Jeff Sese <jsese@xxxxxxxxxxxx> wrote:
hi! Access the 2nd document using the document() function: <xsl:variable name="doc2" select="document('doc2.xml')/> Get the range values using substring (or tokenize() in XSLT 2.0) and the text value from doc2: <xsl:variable name="minRange" select="substring-before($doc2/entry/@n, '-')"/> <xsl:variable name="maxRange" select="substring-after($doc2/entry/@n, '-')"/> <xsl:variable name="doc2Text" select="$doc2/entry"/> (you will have to adjust the paths to suit your real life data) Then select the <entry> elements you are interested in: <xsl:apply-templates select="entry[@n >= $minRange][@n <= $maxRange]"/> Write the template to create the output you're after: <xsl:template match="entry"> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates/> <xsl:value-of select="$doc2Text"/> </xsl:copy> </xsl:template> That template might look a bit strange, but will scale better than the simpler alternative: <xsl:template match="entry">
<entry id='{@id}' type='{@type}' n='{@n}'>
<xsl:value-of select="."/>
<xsl:value-of select="$doc2Text"/>
</entry>
</xsl:template>This one will do what you need for your given input, but the template above is the better solution if you expect the name or number of attribute to change, or if the <entry> element will ever contain anything more than just text. cheers andrew
|

Cart



