1

I am using given below code in XSL file Both xsl and Results.xml are at same location but it cant give output.actually i want to access nodes of Results.xml file to extract data.

<xsl:variable name="fi" select="document('Results.xml')"/>
            <b><xsl:value-of select="$fi/Report/Doc/DName"/></b>
Niaz Hussain
  • 139
  • 1
  • 9
  • What XSLT processor, and how are you loading the stylesheet? There can be issues resolving relative URIs in the `document` function if the processor doesn't know the URI of the stylesheet (for example if you're loading it from an `InputStream` rather than a `File` in Java). – Ian Roberts May 29 '13 at 11:29

1 Answers1

2

When the below XSLT

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:variable name="fi" select="document('Results.xml')"/>  
            <b><xsl:value-of select="$fi/Report/Doc/DName"/></b>
</xsl:template>
</xsl:stylesheet>

transforms below XML

<?xml version='1.0'?>    
<Report>
    <Doc>
        <DName>Sample</DName>
    </Doc>
</Report>

gives the required output

<?xml version='1.0' ?>
<b>Sample</b>
siva2012
  • 457
  • 4
  • 19