[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problems with outputing namespaces

Subject: RE: Problems with outputing namespaces
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 11 Dec 2005 16:47:51 -0000
xslt outputing namespace
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.