aspose file tools*
The moose likes XML and Related Technologies and the fly likes XML doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML doubt" Watch "XML doubt" New topic
Author

XML doubt

Sharmistha Sarkar
Ranch Hand

Joined: Dec 18, 2012
Posts: 44
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

Joined: Dec 18, 2012
Posts: 44
Sorry, a typo, I have created "test.xsl" file not "test.xsd".
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 544
    
    3
Sharmistha Sarkar
Ranch Hand

Joined: Dec 18, 2012
Posts: 44
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

Joined: Jan 18, 2011
Posts: 544
    
    3
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

Joined: Dec 18, 2012
Posts: 44
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

Joined: Jan 18, 2011
Posts: 544
    
    3
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
Bartender

Joined: Oct 14, 2005
Posts: 18908
    
    8

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.
 
Consider Paul's rocket mass heater.
 
subject: XML doubt