• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

XML Namespace Issues

 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 xmlnsds="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!
 
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 28425
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic