This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: namespace dynamic declaration
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Tevoi Andrea" <tevoi at cad dot it>
- Cc: XSL-List at lists dot mulberrytech dot com
- Date: Wed, 26 Jun 2002 14:47:05 +0100
- Subject: Re: [xsl] namespace dynamic declaration
- Organization: Jeni Tennison Consulting Ltd
- References: <621CDB480A325A49BF608434668CB5780ABFDF@tex.cadit.it>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Andrea,
> in Xsl i'd like to do something like this:
>
> <xsl:attribute name="xmlns:myprefix"><xsl:value-of select="any XPath
> expression"/></xsl:attribute>
>
> but for Xsl this is an error (because attribute name begin with
> "xmlns").
Yes; more because XSLT doesn't consider namespace declarations
(xmlns:* attributes) to be attributes.
> How can i do? I mean: i would create a namespace dynamically using
> an XPath expression, because I need to create (by xsl
> transformation) a Schema like this:
>
> <xsd:schema targetNamespace="my dynamic namespace"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:myprefix="my
> dynamic namespace">...
The only method of doing this at the moment is to add a dummy
attribute in the namespace that you want:
<xsl:attribute name="myprefix:dummy"
namespace="{my dynamic namespace}" />
This will force the XSLT processor to add a namespace declaration for
the required namespace and with the required prefix.
The other thing that you might be able to do, if your source document
contains a namespace node for the namespace that you want to add, is
to copy the namespace node from the source to the result, with
something like:
<xsl:copy-of select="namespace::myprefix" />
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list