aspose file tools*
The moose likes XML and Related Technologies and the fly likes XML Namespace Issues 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 "XML Namespace Issues" Watch "XML Namespace Issues" New topic
Author

XML Namespace Issues

Tiago Fernandez
Ranch Hand

Joined: May 16, 2003
Posts: 167
Hello,

I'm trying to produce another XML from an existing XML using XSLT (XML + XSLT = XML), and I'm experiencing namespaces issue. I'm new to this, so I guess the solution might be easy, anyways I'm still confused about handling this.

Scenario A:
---
XML input:
<metadata xmlns="http://www.mycompany.com/schema/odsload" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

XML output:
Contains just data inside the XML input elements


Scenario B:
---
XML input:
<metadata xmlns:ods="http://www.mycompany.com/schema/odsload" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

XML output:
Ok, I've got a well structured XML

Can anybody tell me please what's going on?

Thanks!


Tiago Fernandez
http://www.tiago182.spyw.com/
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

I suppose there is more code in your XSLT than you actually posted there. Probably it is trying to match on element names. When you match on an element name, you are trying to match that name with no namespace (that's an XPath 1.0 default). That fails to match that name in the default namespace, which is what's going on in the first example.
Tiago Fernandez
Ranch Hand

Joined: May 16, 2003
Posts: 167
Thanks for replying Paul. Do you know a better solution for addressing this issue, once I can't modify the XML input? Adding "ds" to xmlns is definitely an ugly workaround
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18882
    
    8

Instead ofwhich doesn't match a "thing" element in the default namespace, you can do this:That matches either a "thing" element in the default namespace or a "thing" element not in any namespace.
[ May 03, 2007: Message edited by: Paul Clapham ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML Namespace Issues