jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes copy nodes using copy-of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "copy nodes using copy-of" Watch "copy nodes using copy-of" New topic

copy nodes using copy-of

Kuan Fan
Ranch Hand

Joined: Jan 25, 2002
Posts: 48
Source xml file:
<BBB ooo="555" ppp="666">
<DDD>d1 </DDD>
<DDD>d2 </DDD>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl utput method = "xml" indent = "yes" />
<xsl:template match = "/" >
<QQQ >
<xsl:copy-of select = "AAA/BBB" />
So far there is no problem. But if I add the namespace to the root element like below:
<AAA xmlns="http://mupc/xml/namespaces/geo" >
<BBB ooo="555" ppp="666">
<DDD>d1 </DDD>
<DDD>d2 </DDD>
The output file is only:
Anyone can help? Thanks.
Mapraputa Is
Leverager of our synergies

Joined: Aug 26, 2000
Posts: 10065
If your elements got namespaced you need to address them with the same namespace in your XSLT. So you need to add namespace declaration:
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0"
xmlns:aaa = "http://mupc/xml/namespaces/geo">
and then use "aaa" prefix to address elements:
<xsl:copy-of select = "aaa:AAA/aaa:BBB" />

Uncontrolled vocabularies
"I try my best to make *all* my posts nice, even when I feel upset" -- Philippe Maquet
I agree. Here's the link: http://aspose.com/file-tools
subject: copy nodes using copy-of
It's not a secret anymore!