I am trying to create an embedded file containing both XML and XSL. The test is based on "XML and XSL in one file" at dpawson.co.uk. The source is as follows:
<?xml-stylesheet type="text/xml" href="#stylesheet"?> <!DOCTYPE doc [ <!ATTLIST xsl:stylesheet id ID #REQUIRED> ]> <doc> <xsl:stylesheet id="stylesheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="xsl:stylesheet" /> </xsl:stylesheet> </doc>
I originally created a working XML and XSL file. XML looks like this:
<?xml-stylesheet type="text/xsl" href="data.xsl"?> <Report> <ReportFor>Test Data</ReportFor> <CreationTime>2009-07-29 05:37:14</CreationTime> </Report>
And the data.xsl file looks like this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:value-of select="Report/ReportFor" /> <xsl:value-of select="Report/CreationTime"/> </xsl:template> </xsl:stylesheet>
Based on this, I am trying to create an embedded XML file containing both XML and XSL.
Currently, this file is as follows:
<?xml-stylesheet type="text/xsl" href="#stylesheet"?> <!DOCTYPE doc [ <!ATTLIST xsl:stylesheet id ID #REQUIRED> ]> <doc> <xsl:stylesheet id="stylesheet" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="xsl:stylesheet" /> <xsl:template match="/"> <xsl:value-of select="Report/ReportFor" /> <xsl:value-of select="Report/CreationTime"/> </xsl:template> </xsl:stylesheet> <Report> <ReportFor>Test Data</ReportFor> <CreationTime>2009-07-29 05:37:14</CreationTime> </Report> </doc>
The problem with this document is that <xsl:value-of> does not retrieve the data represented in the XML section. How can <xsl:value-of> recognize embedded data? Is any special syntax required?
xml xslt
user147050
source share