Jump to content

Setting text in XSLT code


ShivaPrasadm
 Share

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?

Link to comment
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
Link to comment
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

Link to comment
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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...