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(_at_)hotmail(_dot_)com]
Sent: 05 May 2006 14:36
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--