Jump to content
Sign in to follow this  
ShivaPrasadm

Setting text in XSLT code

Recommended Posts

<td width="4%"></td> <td ><xsl:value-of select="node()"/></td> <xsl:variable name="id" select="no"/> <td wrap="nowrap"> <input type="checkbox" value="{name}"> <xsl:attribute name="name"> <xsl:text>CONTROL</xsl:text> <xsl:value-of select="$id"/> </xsl:attribute> <xsl:attribute name="onClick">javascript:Control_Click(this)</xsl:attribute> <xsl:if test="selected= 1"> <xsl:attribute name="checked">checked</xsl:attribute> </xsl:if> </input> </td> Can anyone please explain me what will be printed in the place of CONTROL .. and how?

Share this post


Link to post
Share on other sites

Errr... What will be printed is "CONTROL" itself, combined with the text of the XML's "no" element. Those will be printed as the value of a "name" attribute on the resulting "input" element.You'll have to present a sample XML file if you want a more specific answer.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for the replyplease find the XML code below<modalities> <modality> <name>Any</name> <desc>Any</desc> </modality> <modality> <name>CR</name> <desc>Computed Radiography</desc> </modality> </modalities> I know that ANY and CR will be printed. But i am not able to understand how.can u explain meThank u

Share this post


Link to post
Share on other sites

With your XML, and an XSLT which in full is:

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">	<xsl:template match="/">		<td width="4%"></td><td ><xsl:value-of select="node()"/></td><xsl:variable name="id" select="no"/><td wrap="nowrap"><input type="checkbox" value="{name}"><xsl:attribute name="name"><xsl:text>CONTROL</xsl:text><xsl:value-of select="$id"/></xsl:attribute><xsl:attribute name="onClick">javascript:Control_Click(this)</xsl:attribute><xsl:if test="selected= 1"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if></input></td>	</xsl:template></xsl:stylesheet>

I get the output

<td width="4%"/><td>AnyAnyCRComputed Radiography</td><td wrap="nowrap"><input type="checkbox" value="" name="CONTROL" onClick="javascript:Control_Click(this)"/></td>

The line

<td ><xsl:value-of select="node()"/></td>

outputs the text value of the current node. If this node has any children (as is in this case - the root node has all elements as its children) their collective text is printed.The rest of the XPaths simply don't match any element, which is why they don't output anything related to the document.If you're getting a different result, you'd have to also include the full XSLT.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...