<a> <xsl:attribute name="href"> <xsl:value-of select="/*/properties/property[@name='report']/@value" /> </xsl:attribute> </a>
Is there any way to concat another string to
<xsl:value-of select="/*/properties/property[@name='report']/@value" />
I need to pass some text to href attribute in addition to the report property value
The Concat function takes two input strings as a source and concatenates them defined in XPATH. Below we shall see the arguments it returns and it is very easy to accomplish with XSLT. concat('x') – Gives out error as it got one single string value. Concat('x',' y') – This returns xy.
Definition and Usage The <xsl:value-of> element extracts the value of a selected node. The <xsl:value-of> element can be used to select the value of an XML element and add it to the output.
You could add an empty template to ignore any pre-existing text within the attr element: <xsl:template match="attr[@tag='00080090']/text()"/> . Or you could omit node() in the last select attribute (assuming you only want to copy the attributes of the attr element, not any content).
You can use the rather sensibly named xpath function called concat here
<a> <xsl:attribute name="href"> <xsl:value-of select="concat('myText:', /*/properties/property[@name='report']/@value)" /> </xsl:attribute> </a>
Of course, it doesn't have to be text here, it can be another xpath expression to select an element or attribute. And you can have any number of arguments in the concat expression.
Do note, you can make use of Attribute Value Templates (represented by the curly braces) here to simplify your expression
<a href="{concat('myText:', /*/properties/property[@name='report']/@value)}"></a>
Three Answers :
Simple :
<img> <xsl:attribute name="src"> <xsl:value-of select="//your/xquery/path"/> <xsl:value-of select="'vmLogo.gif'"/> </xsl:attribute> </img>
Using 'concat' :
<img> <xsl:attribute name="src"> <xsl:value-of select="concat(//your/xquery/path,'vmLogo.gif')"/> </xsl:attribute> </img>
Attribute shortcut as suggested by @TimC
<img src="{concat(//your/xquery/path,'vmLogo.gif')}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With