1

I got this simple XML document:

<?xml version="1.0"?>
<document>
<category>
    <id>20504       </id>
    <title>ADSL iranga</title>
    <parent>Kompiuterinio tinklo</parent>
</category>
<category>
    <id>20902</id>
    <title>Akumuliatoriai</title>
    <parent>Baterijos akumuliatoriai</parent>
</category>
</document>

And this xsl template:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="utf-8"/>
<xsl:strip-space elements="*" />

<xsl:template match="/category">
  <xsl:value-of select="id" /><xsl:text>,</xsl:text>
  <xsl:value-of select="title" /><xsl:text>,</xsl:text>
</xsl:template>


</xsl:stylesheet>

I would like to get this simple output:

id,title
id,title
id,title
<...>

However, I don't get my expected delimiter "," Am I using the xsl:text in some wrong manner?

I am using xsltproc for the conversion.

1 Answer 1

2

category is not the root element of your input XML - so your template matches nothing, and the output you see is produced by the built-in template rules.

You need to change:

<xsl:template match="/category">

to:

<xsl:template match="category">

I think you also want to change the second:

<xsl:text>,</xsl:text>

to:

<xsl:text>&#10;</xsl:text>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.