aspose file tools*
The moose likes XML and Related Technologies and the fly likes Why XSL failed to transform the XML when root node has namespace defined? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Why XSL failed to transform the XML when root node has namespace defined?" Watch "Why XSL failed to transform the XML when root node has namespace defined?" New topic
Author

Why XSL failed to transform the XML when root node has namespace defined?

sam joe
Greenhorn

Joined: Jul 23, 2003
Posts: 24
I have an XML and XSL. The XML has a root node called <deployment>, the XSL will pick only <service> node (deep copy) and output. The strange thing is that if <deployment> have attributes 'xmlns' and
'xmlns:java' defined, the XSL doesn't output anything. If I change the the <deployment> node in XML from

to

.

The XSL works perfect. Does anybody know why the namespace affect the XSL transformation? Thanks a million.

sam joe
Greenhorn

Joined: Jul 23, 2003
Posts: 24
Sorry the graemlins ruined the XML. try to repost the XMLs.

Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Since this post is related to XML, I am moving this to our XML and related technologies forum.
Please continue your discussion there.
Regards
Balaji


Spritle Software Blogs
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
You may want to read Ronald Bourret's XML namespaces FAQ.

<deployment> the element's name is "deployment"

<deployment
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

the element's name is "{http://xml.apache.org/axis/wsdd/}:deployment"; the "xmlns" declares the default namespace that the enclosing element belongs to (and any unprefixed element that it contains).

Your XSL matches the <deployment> and <service> it does not match
<{http://xml.apache.org/axis/wsdd/}:deployment>
or
<{http://xml.apache.org/axis/wsdd/}:service>
[ March 15, 2006: Message edited by: Peer Reynders ]
sam joe
Greenhorn

Joined: Jul 23, 2003
Posts: 24
You are right. After I changed the XSL to



It works. Thanks a lot.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why XSL failed to transform the XML when root node has namespace defined?