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

RE: How do you handle namespace prefixes in attribute

Subject: RE: How do you handle namespace prefixes in attribute values in XSLT?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 5 Dec 2002 10:26:35 -0000
handle namespaces using xslt
The answer is to copy the namespace node from the source document to the
result document.

<xsl:template name="part">
  <xsl:copy-of select="@element"/>
  <xsl:copy-of select="namespace::*[name() = substring-before(@element,
':')]"/>

Or you could simply copy ALL namespace nodes:

  <xsl:copy-of select="namespace::*"/>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Matt Seaborn
> Sent: 05 December 2002 08:45
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  How do you handle namespace prefixes in 
> attribute values in XSLT?
> 
> 
> Taking a wsdl file (only as an example, applies to any 
> namespaces xml file) which looks like this
>  
> <?xml version="1.0"?>
> <definitions name="StockQuote" 
> targetNamespace="http://example.com/stockquote.wsdl"
> xmlns:xsd1="http://example.com/stockquote.xsd"
> ...
> <message name="GetLastTradePriceOutput">
> <part name="body" element="xsd1:TradePrice"/>
> </message>
>  
> and you wish to operate on it using XSLT. If the prefix 
> 'xsd1' is not used in the QName of an element then when 
> operating on the XML the 'xsd1' prefix will be lost unless it 
> is explicitly declared in the XSLT. However as the actual 
> prefix of a namespace is considered irrelevant it cannot be 
> known before being given the XML document to transform. 
> Assuming the namespace and its prefix is not known in advance 
> and therefore not declared in the XSLT the prefix-namespace 
> association will not be present in the destination document 
> which renders the attribute value 'xsd1:TradePrice' incorrect 
> if it is placed in the destination (transformed) docoument.
>  
> How should this be handled, as I cannot see how to either 
> preseve the prefix-namespace declaration or ensure the 
> namespace is declared and change the prefix to a correct 
> value in the attribute in the destination document?
>  
> Matt Seaborn
> Software Engineer
> Categoric Software 
> 
> The leader in business process event management technology 
> 
> +44 (0)1932 590900 tel
> +44 (0)1932 590901 fax
> +44 (0)1932 590907 direct
> http://www.categoric.com <http://www.categoric.com/> 
> 
> 
>  
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.