[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
The output seems wrong to me. I can't understand why the xsl:attribute instruction isn't producing an aid:pstyle attribute, which would automatically result in an xmlns:aid namespace declaration being output.
Perhaps it's best to avoid snippets. I ran this stylesheet:
</xsl:stylesheet>
against this source document:
and got this output (whitespace added for clarity):
<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns:sb="http://www.elsevier.com/xml/bk/dtd"
xmlns:ce="http://www.elsevier.com/xml/common/dtd"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
aid:pstyle="" version="5.2" xml:lang="en" docsubtype="chp" id="c0030">
xxxxx
</chapter>
There are some recoverable errors defined in XSLT 1.0 that would entitle a processor to ignore the xsl:attribute instruction (for example, if the name attribute is not a valid QName), but none of them seem to apply here. So in my view, either the stylesheet you are running differs materially from what you have shown us, or there is a bug/nonconformance in your XSLT processor.
However, there is no reason to expect the namespace declaration
xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/"
to appear in your result tree. Namespace declarations are copied from the stylesheet to the result tree only when you use a literal result element. When you use xsl:copy to create an element, it is the namespaces in the source document that are copied. The xmlns:aid in my example appears only because the result tree contains an attribute whose name is in this namespace.
On 23/08/2010 14:47, pankaj.c@xxxxxxxxxxxxxxxxxx wrote:
Re: [xsl] Cannot include namespaces [XSLT 1.0] xsltproc
Subject: Re: [xsl] Cannot include namespaces [XSLT 1.0] xsltproc From: Michael Kay <mike@xxxxxxxxxxxx> Date: Mon, 23 Aug 2010 23:34:19 +0100 |
The output seems wrong to me. I can't understand why the xsl:attribute instruction isn't producing an aid:pstyle attribute, which would automatically result in an xmlns:aid namespace declaration being output.
Perhaps it's best to avoid snippets. I ran this stylesheet:
<xsl:stylesheet version="1.0" xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" xmlns:ce="http://www.elsevier.com/xml/common/dtd" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="chapter"> <xsl:copy> <xsl:attribute name="aid:pstyle"/> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>
</xsl:stylesheet>
against this source document:
<chapter version="5.2" xml:lang="en" docsubtype="chp" id="c0030" xmlns:sb="http://www.elsevier.com/xml/bk/dtd" xmlns:ce="http://www.elsevier.com/xml/common/dtd"> <ce:title>xxxxx</ce:title> </chapter>
and got this output (whitespace added for clarity):
<?xml version="1.0" encoding="UTF-8"?>
<chapter xmlns:sb="http://www.elsevier.com/xml/bk/dtd"
xmlns:ce="http://www.elsevier.com/xml/common/dtd"
xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
aid:pstyle="" version="5.2" xml:lang="en" docsubtype="chp" id="c0030">
xxxxx
</chapter>
There are some recoverable errors defined in XSLT 1.0 that would entitle a processor to ignore the xsl:attribute instruction (for example, if the name attribute is not a valid QName), but none of them seem to apply here. So in my view, either the stylesheet you are running differs materially from what you have shown us, or there is a bug/nonconformance in your XSLT processor.
However, there is no reason to expect the namespace declaration
xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/"
to appear in your result tree. Namespace declarations are copied from the stylesheet to the result tree only when you use a literal result element. When you use xsl:copy to create an element, it is the namespaces in the source document that are copied. The xmlns:aid in my example appears only because the result tree contains an attribute whose name is in this namespace.
Michael Kay Saxonica
On 23/08/2010 14:47, pankaj.c@xxxxxxxxxxxxxxxxxx wrote:
<xsl:stylesheet version="1.0" xmlns:aid=" http://ns.adobe.com/AdobeInDesign/4.0/" xmlns:aid5=" http://ns.adobe.com/AdobeInDesign/5.0/" xmlns:ce=" http://www.elsevier.com/xml/common/dtd" xmlns:xsl=" http://www.w3.org/1999/XSL/Transform">
My xml snippet: <chapter version="5.2" xml:lang="en" docsubtype="chp" id="c0030" xmlns:sb="http://www.elsevier.com/xml/bk/dtd" xmlns:ce=" http://www.elsevier.com/xml/common/dtd"><ce:title>xxxxx</ce:title>
stylesheet snippet
<xsl:template match="chapter"> <xsl:copy> <xsl:attribute name="aid:pstyle"/> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Cannot include namespaces, David Carlisle | Thread | Re: [xsl] Cannot include namespaces, pankaj . c |
Re: [xsl] Question on duplicate nod, Lars Huttar | Date | Re: [xsl] Question on duplicate nod, Hermann Stamm-Wilbra |
Month |