Mano
Mano

Reputation: 143

Populating values inside tags

I have below requirement to do in XSLT.

<SOAPBODY>
<Response Id = "" Name="" input="" >
<Status></Status>
</Response>
</SOAPBODY>

How do I populate the fields inside Response Tag i.e., Id, Name, Input? Those values come from XPath. But when I try to keep them in Tag, it's not successful as XSL is not allowing me to keep an xsl:copy-of selct inside that tag.

What I am trying is

<Response 
Id = "<xsl:value-of select=$Id"
Name="<xsl:value-of select=$Name" 
input=""<xsl:value-of select=$input" >
>
<Status></Status>
</Response>
</SOAPBODY>

Response should be closed only after Status Tag.

Upvotes: 0

Views: 41

Answers (1)

Tim C
Tim C

Reputation: 70618

You need to use Attribute Value Templates here.

<Response 
      Id = "{$Id}"
      Name="{$Name}" 
      input="{$input}">
   <Status></Status>
</Response>

The curly braces indicate it is an expression to be evaluated, rather than output literally, and so {$id}, for example will be replace by whatever the value of the $id variable is.

Upvotes: 1

Related Questions