Estoy intentando crear un archivo incrustado que contenga XML y XSL. La prueba se basa en "XML and XSL in one file" en dpawson.co.uk. La fuente se ve así:Cómo trabajar con un archivo XML y XSL incrustado
<?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>
Originalmente he creado un archivo XML y XSL en funcionamiento. El XML es el siguiente:
<?xml-stylesheet type="text/xsl" href="data.xsl"?>
<Report>
<ReportFor>Test Data</ReportFor>
<CreationTime>2009-07-29 05:37:14</CreationTime>
</Report>
y el archivo data.xsl
se ve así:
<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>
Sobre la base de estos Estoy intentando crear un archivo XML que contiene incrustado XML y XSL.
Actualmente este archivo tiene el siguiente aspecto:
<?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>
El problema de este documento es que el <xsl:value-of>
no recupera los datos representados en la sección XML. ¿Cómo es posible que <xsl:value-of>
reconozca los datos incrustados? ¿Se necesita alguna sintaxis especial?
Ver [http://stackoverflow.com/questions/360628/embed-xsl-into-an-xml-file](http://stackoverflow.com/questions/360628/embed -xsl-into-an-xml-file) – Scoregraphic
Estaba a punto de publicar la sugerencia "incrustar el XML en el XSL", pero como ya se ha respondido: Un enlace es mejor. – Tomalak