xsl-list
[Top] [All Lists]

Re: [xsl] How to force the XSLT processor to retain a namespace declaration on the root element?

2022-03-24 14:00:37

On 24.03.2022 19:56, Roger L Costello costello(_at_)mitre(_dot_)org wrote:
Hi Folks,

I have an XSLT program that processes an XML Schema.

I have a template rule for the root element (xs:schema)

<xsl:template match="xs:schema">
     <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
                          xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/";>
         <xsl:apply-templates/>
     </xs:schema>
</xsl:template>

Notice that the template rule outputs the xs:schema element with two namespace 
declarations: one for the XMLSchema namespace and one for the DFDL namespace.

When I run the XSLT program, I get this output:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
      ...
</xs:schema>

Notice that the DFDL namespace declaration is gone. The XSLT processor has 
moved the declaration down to where the dfdl prefix is used. That is a problem 
because the DFDL processor insists on having the DFDL namespace declared on the 
root element (xs:schema) and the DFDL processor simply will not run unless it 
is there.


So which XSLT processor does that? Or do you happen to use
exclude-result-prefixes="dfdl"?


How do I force the XSLT processor to retain the DFDL namespace declaration on 
the root element?


If you need that namespace declaration in scope for the root of the
literal result element tree and any other elements you could also
consider moving it to the xsl:stylesheet or xsl:transform root of the
stylesheet.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--


<Prev in Thread] Current Thread [Next in Thread>