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

Re: How to take a QName value and make it an attribute

Subject: Re: How to take a QName value and make it an attribute?
From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 1 Aug 2012 16:42:22 +0100
Re:  How to take a QName value and make it an attribute
On 1 August 2012 16:24, Costello, Roger L. <costello@xxxxxxxxx> wrote:
> Hi Folks,
>
> I want to transform the <fault> element in this document:
>
> <Test xmlns:soap="http://www.soap.org">
>     <fault>soap:client</fault>
> </Test>
>
> Note that the value of the <fault> element is
>
>     soap:client
>
> which is a QName.
>
> I want to transform the <fault> element to this:
>
>     <fault soap:client="blah">soap:client</fault>
>
> That is, make the QName value an attribute and assign it the string "blah."
>
> After transformation the XML document is to be this:
>
> <Test xmlns:soap="http://www.soap.org">
>     <fault soap:client="blah">soap:client</fault>
> </Test>
>
> I tried this code:
>
>     <xsl:template match="fault">
>         <xsl:copy>
>             <xsl:variable name="QName" select="." />
>             <xsl:attribute name="{$QName}">blah</xsl:attribute>
>             <xsl:value-of select="." />
>         </xsl:copy>
>     </xsl:template>
>
> But it produces this error message:
>
>     Undeclared prefix in attribute name: soap
>
> What is the proper way to accomplish the desired transformation please?

You can:

- declare the soap namespace on your stylesheet element and your code
will work as it is

or

- add the 'namespace' attribute to xsl:attribute and hard code the
soap namespace in there

or

- add the 'namespace' attribute to xsl:attribute and get the soap
namespace from the source using the various namespace related
functions


-- 
Andrew Welch
http://andrewjwelch.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.