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
<SiteAdaptation File>
...
</SiteAdaptationF ile>
and I'm looking for output like
<SiteAdaptation File xmlns="http://www.sensis.com/AdaptSchema"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocat ion="http://www.sensis.com/AdaptSchema IddAdapt.xsd">
...
</SiteAdaptationF ile>
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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="SiteAda ptationFile"/>
</xsl:template>
<xsl:template match="SiteAdap tationFile">
<xsl:element name="SiteAdapt ationFile">
<xsl:attribut e name="foo" >
<xsl:text>bar </xsl:text>
</xsl:attribute>
<xsl:attribut e name="xmlns" >
<xsl:text>htt p://www.sensis.com/AdaptSchema</xsl:text>
</xsl:attribute>
<xsl:attribut e name="xmlns:xsi " >
<xsl:text>htt p://www.w3.org/2001/XMLSchema-instance</xsl:text>
</xsl:attribute>
<xsl:attribut e name="xsi:schem aLocation" >
<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
<SiteAdaptation File foo="bar">
...
</SiteAdaptationF ile>
I'm sure my question exposes my ignorance of XSLT, and I appreciate
any help, very much.