[oXygen-user] XSLT output root element force namespaces and attributes sequence

Lars Huttar
Tue May 25 17:24:48 CDT 2010


Martijn,
I'm not as expert in XML as those who usually answer this list, but
since it's been several hours, I'll take a shot. Someone please correct
me if I'm wrong.

1) IIRC, identifiers starting with the letters "xml" are reserved...
including namespace prefixes. (See
http://www.w3.org/TR/REC-xml/#sec-common-syn). Thus XML tools may be
(silently?) rejecting your requested namespace prefix "xml". The good
news is that the problem should disappear if you choose a namespace
prefix that doesn't start with "xml".

2) Traditionally, order of attributes in XML is not significant.
Generally, XML tools do not recognize or preserve an ordering. If there
is an option in XSLT 2.0 to specify the ordering of attributes on
output, I don't know about it. Sorry this is not good news. But the
bright side is that whatever processes are downstream should not care
about the order of attributes in the output of the stylesheet. Unless
they're humans.

Lars



On 5/25/2010 8:58 AM, Martijn Van der Graaff wrote:
> Hi 
>
> I need to generate a root element in a output file that contains some attributes and namespaces.
>
> It should like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/6.2.2/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.1/core/impex-dt dt.xsd"
>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>           xmlns="http://www.intershop.com/xml/ns/enfinity/6.2.2/xcs/impex"
>           xmlns:xml="http://www.w3.org/XML/1998/namespace"
>           xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.1/core/impex-dt"
>           major="6"
>           minor="1"
>           family="enfinity"
>           branch="enterprise"
>           build="6.3.1.2.5">
>
> what I get is this:
>
> <enfinity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>           xmlns="http://www.intershop.com/xml/ns/enfinity/6.2.2/xcs/impex"
>           xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.1/core/impex-dt"
>           xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/6.1/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.1/core/impex-dt dt.xsd"
>           major="6"
>           minor="1"
>           family="enfinity"
>           branch="enterprise"
>           build="6.3.1.2.5">
>
> How can I force in XSLT that (xmlns:xml="http://www.w3.org/XML/1998/namespace") is always added to the root element and how can I force on where the attributes are sorted. 
>
> My xslt snippet is:
>
> <xsl:template match="/"...
>   <xsl:element name="enfinity" namespace="http://www.intershop.com/xml/ns/enfinity/6.2.2/xcs/impex">
>             <xsl:attribute name="xsi:schemaLocation">http://www.intershop.com/xml/ns/enfinity/6.1/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.1/core/impex-dt dt.xsd</xsl:attribute>
>             <xsl:namespace name="xsi">http://www.w3.org/2001/XMLSchema-instance</xsl:namespace>
>             <xsl:namespace name="">http://www.intershop.com/xml/ns/enfinity/6.2.2/xcs/impex</xsl:namespace>
>             <xsl:namespace name="xml">http://www.w3.org/XML/1998/namespace</xsl:namespace>
>             <xsl:namespace name="dt">http://www.intershop.com/xml/ns/enfinity/6.1/core/impex-dt</xsl:namespace>
>             <xsl:attribute name="major" select="$major"/>
>             <xsl:attribute name="minor" select="$minor"/>
>             <xsl:attribute name="family" select="$family"/>
>             <xsl:attribute name="branch" select="$branch"/>
>             <xsl:attribute name="build" select="$build"/>
>
>
> Yours,
>
> Martijn
> _______________________________________________
> oXygen-user mailing list
> 
> http://www.oxygenxml.com/mailman/listinfo/oxygen-user
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20100525/d4502e01/attachment.html 


More information about the oXygen-user mailing list