Help coderanch get a
new server
by contributing to the fundraiser
  • 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

Accessing attribute with colons

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to retreive an attribute which has a colon in the name.

XML looks like

XSLT looks like

When I run the xslt I get Error in XPath, invalid prefix. Can somebody help me access this please.


Thanks Praveen.
 
Marshal
Posts: 28271
95
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
In the sample of your input XML document you left out the part where it declares the namespace whose prefix is "c:" in that document.

It isn't the case that the name of the attribute "contains a colon", from the XML point of view. It is the case that the attribute's name is in a certain namespace, and you have declared that in this document, that namespace will be described by the prefix "c:".

So if you want to search for attributes in that namespace, you have to declare the namespace. That means that in your XSLT document, you have to declare that namespace and specify that its prefix will be "c:" in the XSLT document as well.
 
JPraveen Kumar
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually I am not generating the xml here, its the output of a tool that I am using. I am pasting the file here. Please let me know if there s any way that I can get the value myName and the type of the element from this file.

(I am adding space after each colon to avoid the smileys)


Thanks Praveen.

 
Paul Clapham
Marshal
Posts: 28271
95
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
What I already said. Here's your namespace declaration:Include that declaration in your XSLT as well.

(If you scroll down when posting you'll see the checkbox "Disable smilies in this post".)
 
Just the other day, I was thinking ... about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic