weibster Posted November 30, 2006 Share Posted November 30, 2006 I'm trying to transform from an xml doc to another xml doc using xsl. For examplexml file:<c><aa><a><nameid>123</nameid><dob>2005-10-10</dob></a></aa><bb><b><nameid>123</nameid><address>blah</address></b></bb></c>xsl file:<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/"><xsl:for-each select="/c"><aa><a><xsl:copy-of select="aa/a/nameid"/><xsl:copy-of select="aa/a/dob"/><xsl:copy-of select="bb/b/nameid"/><xsl:copy-of select="bb/b/address"/></a></aa></xsl:for-each></xsl:template></xsl:stylesheet>Now the above xml and xsl combination works. However, when the xml file has a tag with xmlns like the one below, it doesn't work anymore<c xmlns="aaa"><aa><a><nameid>123</nameid><dob>2005-10-10</dob></a></aa><bb><b><nameid>123</nameid><address>blah</address></b></bb></c>Does anyone have any ideas why?Thanks Link to comment Share on other sites More sharing options...
weibster Posted November 30, 2006 Author Share Posted November 30, 2006 Am I the only person who has ever ran into something like this? Link to comment Share on other sites More sharing options...
boen_robot Posted December 1, 2006 Share Posted December 1, 2006 Sure you're not...XPath is sencetive to a namespace, that's all.If you change /c to /c{aaa} where the contents of the parenthesis is the namespace URI, it will work. If you want to select that element regardless of it's namespace, use /*[local-name()='c'] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now