Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML doubt

 
Sharmistha Sarkar
Ranch Hand
Posts: 49
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a xml "test.xml"


I created a "test.xsd" to generate the output.

My Required output is,

prodName HAMMER HG2606
prodNo 32456240
price $30.00


But I am getting output like
prodName
prodNo
price

I am not getting the inline values of these nodes after hitting in browser. Can someone help me out?
 
Sharmistha Sarkar
Ranch Hand
Posts: 49
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, a typo, I have created "test.xsl" file not "test.xsd".
 
g tsuji
Ranch Hand
Posts: 649
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sharmistha Sarkar
Ranch Hand
Posts: 49
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, amazing . Thanks tsuji , It is working. Could you please tell me ; is normalize-space() take the values of the xml nodes? I thought it is dealing with removing space.
 
g tsuji
Ranch Hand
Posts: 649
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
normalize-space() basically trim, ie eliminate the leading and trailing whitespaces, and collapse any consecutive whitespaces within by replacing them by a simple space. Whitespace is a technical term: it means cr, lf, space, tab.

The normalize-space() here is understood to get the text content of the context node. You can write it like normalize-space(.) or normalize-space(text()), if you think that's clearer to you.
 
Sharmistha Sarkar
Ranch Hand
Posts: 49
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I understood here, normalize-space() is not working as eliminating space. It is to get the value of a particular xml node. Can you refer me any link or something which describes XSLT tutorial better. I mean like this kind of methods [ something more than basic ].
 
g tsuji
Ranch Hand
Posts: 649
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The various xpath functionalities (including its functions) are specified in the w3c recommendation(s). Start with xpath 1.0 would not hurt and conceptually simpler than enhanced 2.0.
http://www.w3.org/TR/xpath/
 
Paul Clapham
Sheriff
Pie
Posts: 20153
23
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sharmistha Sarkar wrote:Yes, I understood here, normalize-space() is not working as eliminating space. It is to get the value of a particular xml node.


Well, not exactly. The "normalize-space" function does do a particular sort of eliminating space. But the point here is that because the version of the function with no parameters was used, it does that to the context node. The other version of the function takes one parameter, and in that case the function does the space-elimination on the value of that parameter.

The "context node" concept is an important one. If you find yourself going through a tutorial which doesn't mention it, then it's not a good tutorial. For example a description of <xsl:for-each> should mention the context node.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic