Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Adding unused namespace in output using xslt. >Thread Next - Re: Adding unused namespace in output using xslt. Re: Adding unused namespace in output using xslt.To: NULL Date: 10/7/2008 2:02:00 PM
Martin Honnen wrote:
> Jan Obrestad wrote:
>
>> Is it possible using xslt to add a namespace declaration in the output
>> document? The declaration should be with prefix, like this:
>> xmlns:ge="http://earth.google.com/kml/2.0"
>
>
> Sure, put it where you need it e.g.:
> <xsl:template match="/">
> <foo xmlns:ge="http://earth.google.com/kml/2.0">
> <xsl:apply-templates/>
> </foo>
> </xsl:template>
>
> Or simply doing
> <xsl:stylesheet
> xmlns:ge="http://earth.google.com/kml/2.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>
> <xsl:template match="/">
> <foo>
> <xsl:apply-templates/>
> </foo>
> </xsl:template>
>
> </xsl:stylesheet>
>
> should suffice.
>
>
Thank you for a swift reply.
I tried your suggestion, but couldn't get it to work on my concrete
problem.
My problem is this. I have this xslt:
<?xml version="1.0" encoding="UTF-8" ?>
<!--Stylesheet to strip element prefixes and declare e2b namespace as
default-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.e2b.no/XMLSchema"
xmlns:e2b="http://www.e2b.no/XMLSchema"
>
<xsl:output method="xml" indent="yes" encoding="iso-8859-1"/>
<xsl:param name="params"/>
<xsl:template match="node()">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="./@*"/>
<xsl:value-of select="text()"/>
<xsl:apply-templates select="./*"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
This script removes the e2b prefix and make that namespace the default
The root element then becomes:
<Interchange xmlns="http://www.e2b.no/XMLSchema">
But our client wants the root element to look like this:
<Interchange xmlns="http://www.e2b.no/XMLSchema"
xmlns:e2bCard="http://www.e2b.no/XMLSchema/Card"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="e2b_Invoice_Interchange_v3p0.xsd">
I tried adding these namespaces to the xsl:styleshhet element, but they
did not appear in the output xml.
Do you have any idea how to achieve this?
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
