Hi Jeff,
Please try this as well, and see if its useful for you.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:variable name="doc" select="document('file2.xml')" />
<xsl:template match="/root">
<root>
<xsl:for-each select="entry[(@n >=
substring-before($doc/root/entry/@n,'-')) and (@n <=
substring-after($doc/root/entry/@n,'-'))]">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:value-of select="concat(., ' ', $doc/root/entry)" />
</xsl:copy>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
This stylesheet is applied to the XML:
<root>
<entry id='1' type='t' n='1'>some text</entry>
<entry id='1' type='t' n='2'>some text</entry>
<entry id='1' type='t' n='3'>some text</entry>
<entry id='1' type='t' n='4'>some text</entry>
<entry id='1' type='t' n='5'>some text</entry>
</root>
For file2.xml as:
<root>
<entry id='1' type='t' n='3-4'>some text2</entry>
</root>
The output produced is:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<entry id="1" type="t" n="3">some text some text2</entry>
<entry id="1" type="t" n="4">some text some text2</entry>
</root>
Regards,
Mukul
On 7/19/06, Jeff Sese <jsese(_at_)asiatype(_dot_)com> wrote:
hi!
i'm trying to match an element that may have an attribute value that is
in a range format (1-5), and is located on a separate xml document; how
can i get my xpath to match?
xml source:
<entry id='1' type='t' n='1'>some text</entry>
<entry id='1' type='t' n='2'>some text</entry>
<entry id='1' type='t' n='3'>some text</entry>
<entry id='1' type='t' n='4'>some text</entry>
<entry id='1' type='t' n='5'>some text</entry>
xml source 2:
<entry id='1' type='t' n='1-5'>some text2</entry>
needed output:
<entry id='1' type='t' n='1'>some text some text2</entry>
<entry id='1' type='t' n='2'>some text some text2</entry>
<entry id='1' type='t' n='3'>some text some text2</entry>
<entry id='1' type='t' n='4'>some text some text2</entry>
<entry id='1' type='t' n='5'>some text some text2</entry>
thanks,
--jeff
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--