Subject: RE: Creating namespace declarations solely for QName attribute values
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 16 Oct 2008 22:53:23 +0100
|
Are you using XSLT 2.0? The xsl:namespace instruction was invented to make
this kind of job easier.
Michael Kay
http://www.saxonica.com/
> -----Original Message-----
> From: Jeff Greif [mailto:jeff.greif@xxxxxxxxx]
> Sent: 16 October 2008 22:45
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Creating namespace declarations solely for
> QName attribute values
>
> We are trying to replace namespaces consistently in the
> namespace declarations of a document, thus preserving the
> prefixes so the QName attribute values remain valid.
>
> That is, given a source document like this:
>
> <schema targetNamespace="urn:target" xmlns:t="urn:target"
> xmlns:i="urn:imported">
> <import namespace="urn:imported"/>
> <element name="something" type="i:ImportedType"/> </schema>
>
> The key feature of this document is that no element or
> attribute in the document is in either of the explicitly
> declared namespaces.
> These namespaces are only referenced explicitly in attribute
> values and implicitly in the QName-valued attribute 'type'.
>
> The idea is to change urn:target to urn:target1 and urn:imported to
> urn:imported1 (based on a map of these conversions read into
> the XSLT using the document() function). None of the
> namespaces involved in this conversion can be declared in the
> stylesheet, but are determined from the map.
>
> We know how to change the value of any attribute, the
> namespace of any element or attribute using this map, but we
> don't see yet how to change the association of a prefix with
> a namespace, so that the prefix 'i' will be associated with
> the namespace "urn:imported1" in the result document,
> effectively changing the namespace implied by the value of
> the 'type' attribute in the result document, *when there is
> no element or attribute in the source document that has the
> namespace corresponding to that prefix*.
>
> We are trying to avoid having to know which are attributes
> with QName values and having to transform their values to
> somehow conform to prefixes used in the result doc.
>
> Is there a way to do this in XSLT, given that matching on
> namespace nodes is not possible, and we have been unable to
> find a way to create namespace nodes in a template except by
> naming an element or attribute using the prefix in question?
> Would a solution involve creating an attribute with the given
> prefix and namespace, to change the namespace nodes of the
> containing element, while avoiding having the attribute
> appearing in the result document?
>
> Jeff
|