Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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: 26475
81
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: 26475
81
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".)
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic