I am trying to create an embedded file containing both XML and XSL. The test is based on "XML and XSL in one file" on dpawson.co.uk. The source looks like this:
<?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">
<!-- any xsl:import elements -->
<xsl:template match="xsl:stylesheet" />
<!-- rest of your stylesheet -->
</xsl:stylesheet>
<!-- rest of your XML document -->
</doc>
Originally I have made a working XML and XSL file. The 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 these I'm trying to create an embedded XML file containing both XML and XSL.
Currently this file looks like this:
<?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">
<!-- any xsl:import elements -->
<xsl:template match="xsl:stylesheet" />
<!-- rest of your stylesheet -->
<xsl:template match="/">
<!-- ... -->
<xsl:value-of select="Report/ReportFor" />
<!-- ... -->
<xsl:value-of select="Report/CreationTime"/>
<!-- ... -->
</xsl:template>
</xsl:stylesheet>
<!-- rest of your XML document -->
<Report>
<ReportFor>Test Data</ReportFor>
<CreationTime>2009-07-29 05:37:14</CreationTime>
</Report>
</doc>
The problem with this document is that the <xsl:value-of>
does not retrieve the data represented in the XML section. How is it possible for <xsl:value-of>
to recognize the embedded data? Is some special syntax needed?