Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print < and > symbols which are part of text..?

Tags:

xslt

xslt-1.0

I just can't figure out a way to output string something like :

<xml version="1.0" encoding="UTF-8">

this is what i tried:

<xsl:variable name="lessThan" select="&#x3C;"/>
<xsl:variable name="GreaterThan" select="&#x3E;"/>
    <xsl:value-of select="$lessThan"/>
    <xsl:text>xml version="1.0" encoding="UTF-8"</xsl:text>
    <xsl:value-of select="$GreaterThan"/>

but this is the output i'm getting:

&lt;xml version="1.0" encoding="UTF-8"&gt;

I also tried doin something like this:

<xsl:text><xml version="1.0" encoding="UTF-8"></xsl:text>

but the editor simply doesn't let me do this.It throws an error to match with end tag

PS:I am not well versed in xslt so Do please reply even if the question sounds naive.

like image 295
FarSh018 Avatar asked Dec 11 '22 15:12

FarSh018


2 Answers

try this:

 <xsl:text disable-output-escaping="yes">&lt;xml version="1.0" encoding="UTF-8"&gt;</xsl:text>
like image 198
Navin Rawat Avatar answered Jan 12 '23 16:01

Navin Rawat


To make your test xslt working you can use disable-output-escaping = "yes"

Changed xlst:

<xsl:variable name="lessThan" select="'&#x3C;'"/>
<xsl:variable name="GreaterThan" select="'&#x3E;'"/>
<xsl:value-of  disable-output-escaping = "yes" select="$lessThan"/>
<xsl:text>xml version="1.0" encoding="UTF-8"</xsl:text>
<xsl:value-of disable-output-escaping = "yes" select="$GreaterThan"/>

Update: Only a guess you try to generate a xml declaration.

 <?xml version="1.0" encoding="utf-8"?>

This should be done with xsl:output

<xsl:output method="xml" encoding="utf-8"/>
like image 32
hr_117 Avatar answered Jan 12 '23 16:01

hr_117