Subject: RE: Problems with outputing namespaces
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 11 Dec 2005 16:47:51 -0000
|
You're creating the element with:
<xsl:element name="policy"
namespace="http://www.foo.net/cml/NetworkProtector/fwm">
The XSLT 1.0 specification says:
"XSLT processors may make use of the prefix of the QName specified in the
name attribute when selecting the prefix used for outputting the created
element as XML; however, they are not required to do so."
It looks as if you're out of luck: you've chosen an XSLT processor that (at
least in this situation) ignores the [absence of a] prefix in the name
attribute.
Many XSLT 1.0 processors do make use of the prefix (or its absence), and
XSLT 2.0 mandates that they should do so unless there's a conflict with
another use of the same prefix:
"The prefix of the lexical QName specified in the name attribute (or the
absence of a prefix) is copied to the prefix part of the expanded-QName
representing the name of the new element node. In the event of a conflict
this prefix (or absence of a prefix) may subsequently be changed during the
namespace fixup process (see 5.7.3 Namespace Fixup)."
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Charlie Consumer [mailto:faceless1976@xxxxxxxxx]
> Sent: 09 December 2005 16:53
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Problems with outputing namespaces
>
> Hi,
>
> I'm doing a XML to XML transformation with a
> stylesheet. The problem I'm having it that the xmlns
> attribute is being outputted differently than it came
> in. So before it looks like:
>
> <policy
> xmlns="http://www.foo.net/cml/NetworkProtector/fwm"
> ... >
>
> after it looks like:
>
> <fwm:policy
> xmlns:fwm="http://www.foo.net/cml/NetworkProtector/fwm"
> ...>
>
> I'm using the JDK 1.5 JAXP 1.3 which is XSLTC as my
> stylesheet library. Previous I had been using XALAN.
> Here is the first portion of my stylesheet:
>
> <xsl:stylesheet version="1.0"
> xmlns:npcommon="http://www.foo.net/cml/NetworkProtector/common"
> xmlns:fwm="http://www.foo.net/cml/NetworkProtector/fwm"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
> <xsl:output encoding="UTF-8" indent="yes"
> method="xml"/>
>
> <xsl:template match="fwm:policy">
> <xsl:variable name="nodesToMesh"
> select="$localMesh/member[not(@component=$localComponent)
> and not(@removed)]"/>
>
> <xsl:element name="policy"
> namespace="http://www.foo.net/cml/NetworkProtector/fwm">
> <xsl:copy-of select="@*"/>
> <xsl:apply-templates mode="access"
> select="$nodesToMesh"/>
> <xsl:apply-templates select="fwm:Policy"/>
> <xsl:apply-templates mode="ipsec"
> select="$nodesToMesh"/>
> <xsl:apply-templates select="fwm:IPSECRules"/>
> <xsl:apply-templates select="fwm:CommonLists"/>
> <xsl:apply-templates
> select="fwm:SecurityGateways"/>
> <xsl:apply-templates select="fwm:MessageConfig"/>
> <xsl:apply-templates
> select="fwm:ProxyRedirectRule"/>
> <xsl:apply-templates
> select="fwm:VpnAdvancedSettings"/>
> <xsl:apply-templates select="fwm:TuningSetting"/>
> </xsl:element>
> </xsl:template>
>
> What I'm trying to accomplish is just no prefixes with
> fwm: and my xmlns attribute to carry no xmlns:fwm, but
> instead be just xmlns. Why is this not working?
>
> Thanks
> Charlie
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
| Current Thread |
|
Jon Gorman - 9 Dec 2005 17:29:13 -0000
drkm - 9 Dec 2005 17:27:16 -0000
Michael Kay - 11 Dec 2005 16:48:03 -0000 <=
|
|