xml - Line breaks occurring in XSLT template -
i have simple xml this...
<?xml version="1.0" encoding="utf-8"?> <root> <sentence> <word1>the</word1> <word2>cat</word2> <word3>sat</word3> <word4>on</word4> <word5>the</word5> <word6>mat</word6> </sentence> <sentence> <word1>the</word1> <word2>quick</word2> <word3>brown</word3> <word4>fox</word4> <word5>did</word5> <word6>nothing</word6> </sentence> </root>
what want able process xslt create sentence, the~cat~sat~on~the~mat
(this simplified illustration of want able do, stumbling block now).
my xslt looks this;
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output indent="no" /> <xsl:template match="text()[not(string-length(normalize-space()))]"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:text>
</xsl:text> <xsl:apply-templates /> </xsl:template> <xsl:template match="/root/sentence"> <xsl:apply-templates /> <xsl:text>
</xsl:text> </xsl:template> <xsl:template match="word1"> <xsl:value-of select="text()" /> ~ </xsl:template> <xsl:template match="word2"> <xsl:value-of select="text()" /> ~ </xsl:template> <xsl:template match="word3"> <xsl:value-of select="text()" /> ~ </xsl:template> <xsl:template match="word4"> <xsl:value-of select="text()" /> ~ </xsl:template> <xsl:template match="word5"> <xsl:value-of select="text()" /> ~ </xsl:template> <xsl:template match="word6"> <xsl:value-of select="text()" /> ~ </xsl:template> </xsl:stylesheet>
if run stylesheet on xml each word on line of s own, tilda on next line, this
<?xml version="1.0" encoding="utf-8"?> ~ cat ~ sat ~ on ~ ~ mat ~ ~ quick ~ brownish ~ fox ~ did ~ nil ~
if remove tildas get
thecatsatonthemat
it looks me (and new xslt stuff), inclusion of tilda on new line in forcing new line.
so, how can forcefulness output template on 1 line? (my final requirement more formatting elements, , and spaces pad elements out - i'll come later).
thanks in anticipation
change ~
<xsl:text>~</xsl:text>
xml xslt
No comments:
Post a Comment