xsl-list
[Top] [All Lists]

xsl:copy-of + xsi namespace

2004-10-01 11:24:22
hi all,

I have a question related to the copy-of function in xslt 2.0:

I would like to deep copy a piece of my source XML to a new XML file, without declaring all Namespaces of my source XML in my copied excerpt.

I know, I can make use of the xsl:copy-of function with the copy-namespaces attribute set to 'no'. Then, my targetnamespace is indeed copied, and other Namespace declarations of my source XML document (such as the foo NS) are omitted. However, I still would like to keep the xmlns:xsi Namespace declaration in the copied excerpt (as this would make the latter self-contained).

Does anyone knows how to do this? I provide an illustrative example below.

Many thanks in advance
chris


source XML:
----------

<foo:wrapper xmlns:foo="http://foo"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<!-- start excerpt to be copied -->
<bar:excerpt xmlns:bar="http://bar"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >
   <bar:subject>blablabla</bar:subject>
   <bar:subject>blablabla</bar:subject>
<dc:author xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >blablabla</dc:author>
 </bar:excerpt>
<!-- end excerpt to be copied -->
</foo:wrapper>

output XML:
----------

<bla:container xmlns:bla="http://bla"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<!-- start copied excerpt -->
<bar:excerpt xmlns:bar="http://bar"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >
   <bar:subject>blablabla</bar:subject>
   <bar:subject>blablabla</bar:subject>
<dc:author xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; >blablabla</dc:author>
   </bar:excerpt>
<!-- end copied excerpt -->
</bla:container>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



<Prev in Thread] Current Thread [Next in Thread>
  • xsl:copy-of + xsi namespace, chris strub <=