• 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

In XSLT , is reference to root node required to access child node of root node ?

 
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have following xml file

In the xslt code created to acess student node, do I need to access it though root context as follows?


or can I access it without referencing root context ?


If not, then how can student node be accesses without reference to root node class as follows ?


This is given in an example in the tutorial on the net.

Please explain.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Explain what you have tried so far. There are a few different ways to program with XSLT.


This will fire when each student element is read.



Here you can iterate through all child student elements.
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) To access an element in xml doc, do we not need to "select" root node first ? This is what I came across in the book "using xslt" by Michael Floyd



class is document node and student is child node of class.

If I want to access student node, do I not need to address class node first ? I was reading an article which stated " every xslt doc must have a root node"


In this case root node is addressed.



In this xslt code, root node is not addressed. Is this correct ?


Again, in this code, root node is not addressed. So will this code work ? If yes, then does it mean that addressing the root node syntax is not required ?

Please explain the rule for root node , when is it required to address the root node and when not.

2) I tried to use these codes in Awgar stone xslt processor. But when I select the xml , xslt and output files and select to transform , I get an error message
"The version attribute is required at this location.

Line 1 : <?xml encoding="UTF-8" version="1.0"?>."

I am not sure, why do I get this error. I could not test it at my end.

 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

...I was reading an article which stated " every xslt doc must have a root node"





Yes, this is correct. Every XLST document must have a root node. In the document above the root node is the stylesheet element.
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what I was asking is about the root node of the xml document that is being transformed. Does an xslt not need to address root node of xml doc to access children nodes ?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried this out to find the answer to your question? If you don't process the root node, can you still process the contents of the root node?
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am unable to test it on my end. Please my read post , I have mentioned that I am getting error while using xslt procesor and that also is a problem. Why am I getting such error ?

thanks
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you feel that you are unable to test this? All you need is a copy of Internet Explorer. IE has a built-in XSLT processor.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic