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

RE: Declaring ns-prefixes for namespaces imported with

Subject: RE: Declaring ns-prefixes for namespaces imported within a generated xml:schema
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 5 May 2006 14:47:58 +0100
xsl namespace declaring in element
XSLT 2.0 has an xsl:namespace instruction for this purpose - it generates a
namespace node in the result tree, in the same way as xsl:attribute
generates an attribute node.

For XSLT 1.0 there's a workaround, so long as your processor supports
xx:node-set(): you create an element in a temporary tree with the
appropriate namespace, and then copy its namespace nodes:

<xsl:variable name="dummy">
  <xsl:element name="{$prefix}:dummy" namespace="{$uri}"/>
</xsl:variable>
<xsl:copy-of select="xx:node-set($dummy)//namespace::*"/>

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Robert Melskens [mailto:tridero@xxxxxxxxxxx] 
> Sent: 05 May 2006 14:36
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Declaring ns-prefixes for namespaces imported 
> within a generated xml:schema
> 
> Hello,
> 
> Can anyone help me with the following simplified version of 
> my problem?
> 
> I have a lot of XML-Schema's in which a lot of elements are 
> created at global level. Each of them is created by a 
> different creator and they all have their own target 
> namespace. They all can refer to eachother and we don't know 
> all schema's which will be used.
> Besides that I also have XML files describing a specific form 
> (lets call them form-instances).
> Within each form-instance the elements are listed which are 
> used within the related form.
> In future a lot of different forms (and form-instances) will 
> be created.
> 
> In the future we will also receive a lot of XML-instances, 
> representing the content of the form.
> To be able to validate these XML-instances we would like to 
> generate an XML-Schema for each form-instance.
> 
> Using XSLT I create this, top level, XML-schema which imports 
> all schema's containing one or more of the elements used 
> within the form-instance.
> I also create a top level element in which I place the needed 
> elements which refer to the elements within the other XML-Schema's.
> To be able to distinguish the namespace of each element I 
> need to create a prefix for each namespace which I will use 
> within the 'ref' attribute of the 'xs:element' element.
> Since I don't know beforehand which namespace will be 
> imported and don't know all possible namespaces I can't hard 
> code the namespaces within my 'xsl:stylesheet' element.
> As most of us will know declaring a prefix for each namespace 
> needs to be done using the 'xmlns:xx' attribute.
> However this attribute can't be created by using the 'xsl:attribute' 
> element.
> 
> This is where de development of my stylesheet drives against 
> a big wall.
> 
> Does anyone knows a way to overcome this problem? Thanks in advance.
> 
> _________________________________________________________________
> Krijg direct antwoord op je vragen: MSN Messenger 
> http://www1.imagine-msn.com/Messenger/Default2.aspx

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-2011 All Rights Reserved.