Correct way of writing xsl:value-of in XSLT

headboy

New Member
I am trying to write XSLT to transform my XML from one format to another. When I apply my \[code\].xslt\[/code\] file to the XML file in VS 2010, the output XML structure is created without any problem. But it does not fill in data expected by processing \[code\]xsl:value-of\[/code\]. When I use \[code\]XMLSpy\[/code\] and evaluate the \[code\]XPath\[/code\] expression, it says \[code\]no result\[/code\] for the expressions in following XSLT. But when I use \[code\]node()\[/code\] function at the end of the XPath expression, it shows the value! [*]What is the correct way of writing XPath?[*]Does \[code\]node()\[/code\] and \[code\]text()\[/code\] kind of functions really necessary everytime to read the element content (when it has no child elements) ? If no, why XmlSpy too does not give result without those functions?[*]Sometimes (when i change the template match value from "/" to the "ServiceMessage" ) while debugging XSLT, VS 2010 steps into built in template rules. Why is it so? How can I get rid of built in templates in VS 2010?I have followed w3school tutorial to begin with. I am new to XSLT. Here is my XML which I want to transform to some other XML format.\[code\]<ServiceMessage xmlns="http://requestservice/requests" xmlns:req="http://requestservice/requests/xmlstds"><TypeOfReq> General </TypeOfReq><Details> <Id> 123456789 </Id> <SenderDetails> <Sender id="345"></Sender> </SenderDetails></Details></ServiceMessage>\[/code\]This is my XSLT\[code\]<?xml version="1.0" encoding="utf-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <request> <requestType> <xsl:value-of select="ServiceMessage/TypeOfReq" /> </requestType> <Id> <xsl:value-of select="ServiceMessage/Details/Id"/> </Id> <senderId> <xsl:value-of select="ServiceMessage/Details/SenderDetails/Sender/@id"/> </senderId> </request> </xsl:template></xsl:stylesheet>\[/code\]
 
Back
Top