C
CB
I have a group of documents that previously had no schema, now I have
a schema, and I want to use XSLT to fixup the documents by inserting
the namespace reference.
In other words, my input document looks like
<SiteAdaptationFile>
...
</SiteAdaptationFile>
and I'm looking for output like
<SiteAdaptationFile xmlns="http://www.sensis.com/AdaptSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sensis.com/AdaptSchema IddAdapt.xsd">
...
</SiteAdaptationFile>
Here is my xslt script. The foo attribute is just a dummy, and I
put it in because Xalan complains about the other attribute names,
and ignores them. i.e., i wanted to see something change.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="SiteAdaptationFile"/>
</xsl:template>
<xsl:template match="SiteAdaptationFile">
<xsl:element name="SiteAdaptationFile">
<xsl:attribute name="foo" >
<xsl:text>bar</xsl:text>
</xsl:attribute>
<xsl:attribute name="xmlns" >
<xsl:text>http://www.sensis.com/AdaptSchema</xsl:text>
</xsl:attribute>
<xsl:attribute name="xmlns:xsi" >
<xsl:text>http://www.w3.org/2001/XMLSchema-instance</xsl:text>
</xsl:attribute>
<xsl:attribute name="xsi:schemaLocation" >
<xsl:text>http://www.sensis.com/AdaptSchema
IddAdapt.xsd</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
My actual output is
<SiteAdaptationFile foo="bar">
...
</SiteAdaptationFile>
I'm sure my question exposes my ignorance of XSLT, and I appreciate
any help, very much.
a schema, and I want to use XSLT to fixup the documents by inserting
the namespace reference.
In other words, my input document looks like
<SiteAdaptationFile>
...
</SiteAdaptationFile>
and I'm looking for output like
<SiteAdaptationFile xmlns="http://www.sensis.com/AdaptSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sensis.com/AdaptSchema IddAdapt.xsd">
...
</SiteAdaptationFile>
Here is my xslt script. The foo attribute is just a dummy, and I
put it in because Xalan complains about the other attribute names,
and ignores them. i.e., i wanted to see something change.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xslutput method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="SiteAdaptationFile"/>
</xsl:template>
<xsl:template match="SiteAdaptationFile">
<xsl:element name="SiteAdaptationFile">
<xsl:attribute name="foo" >
<xsl:text>bar</xsl:text>
</xsl:attribute>
<xsl:attribute name="xmlns" >
<xsl:text>http://www.sensis.com/AdaptSchema</xsl:text>
</xsl:attribute>
<xsl:attribute name="xmlns:xsi" >
<xsl:text>http://www.w3.org/2001/XMLSchema-instance</xsl:text>
</xsl:attribute>
<xsl:attribute name="xsi:schemaLocation" >
<xsl:text>http://www.sensis.com/AdaptSchema
IddAdapt.xsd</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
My actual output is
<SiteAdaptationFile foo="bar">
...
</SiteAdaptationFile>
I'm sure my question exposes my ignorance of XSLT, and I appreciate
any help, very much.