• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

copy nodes using copy-of

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Source xml file:
<AAA>
<BBB ooo="555" ppp="666">
<DDD>d1 </DDD>
<DDD>d2 </DDD>
</BBB>
</AAA>
xslt:
<?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" />
</QQQ>
</xsl:template>
</xsl:stylesheet>
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>
</BBB>
</AAA>
The output file is only:
<QQQ/>
Anyone can help? Thanks.
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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" />
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic