Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try something like this instead. It will output any attributes before the text of the element.</p> <p><strong>XML Input</strong></p> <pre><code>&lt;projects&gt; &lt;project&gt; &lt;name ID="A"&gt;Shockwave&lt;/name&gt; &lt;language&gt;Ruby&lt;/language&gt; &lt;/project&gt; &lt;project&gt; &lt;name ID="B"&gt;Other&lt;/name&gt; &lt;language&gt;Erlang&lt;/language&gt; &lt;/project&gt; &lt;/projects&gt; </code></pre> <p><strong>XSLT 1.0</strong></p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="text"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="project"&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;xsl:text&gt;&amp;#xA;&lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@*"&gt; &lt;xsl:value-of select="."/&gt; &lt;xsl:if test="../text() or parent::project"&gt; &lt;xsl:text&gt;,&lt;/xsl:text&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;xsl:template match="*[ancestor::project]"&gt; &lt;xsl:apply-templates select="@*"/&gt; &lt;xsl:if test="preceding-sibling::*"&gt; &lt;xsl:text&gt;,&lt;/xsl:text&gt; &lt;/xsl:if&gt; &lt;xsl:value-of select="."/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>Output</strong></p> <pre><code>A,Shockwave,Ruby B,Other,Erlang </code></pre> <p><strong>EDIT FOR NEW REQUIREMENTS</strong></p> <p><strong>XML Input</strong></p> <pre><code>&lt;projects&gt; &lt;project&gt; &lt;name ID="A" StartDate='2012-01-01' EndDate='2012-01-30'&gt;Shockwave&lt;/name&gt; &lt;language&gt;Ruby&lt;/language&gt; &lt;Manager ID="M1"&gt;Nathan&lt;/Manager&gt; &lt;/project&gt; &lt;project&gt; &lt;name ID="B" StartDate='2012-01-01' EndDate='2012-02-30'&gt;Other&lt;/name&gt; &lt;language&gt;Erlang&lt;/language&gt; &lt;Manager ID="M2"&gt;Kristi&lt;/Manager&gt; &lt;/project&gt; &lt;/projects&gt; </code></pre> <p><strong>XSLT 1.0</strong></p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output method="text"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match="project"&gt; &lt;xsl:apply-templates select="@*|node()"/&gt; &lt;xsl:text&gt;|&lt;/xsl:text&gt; &lt;/xsl:template&gt; &lt;xsl:template match="@*"&gt; &lt;xsl:if test="count(parent::*/@*)=1 and not(parent::project)"&gt; &lt;xsl:text&gt;;&lt;/xsl:text&gt; &lt;/xsl:if&gt; &lt;xsl:value-of select="."/&gt; &lt;xsl:if test="parent::project or (last())"&gt; &lt;xsl:text&gt;;&lt;/xsl:text&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;xsl:template match="*[ancestor::project]"&gt; &lt;xsl:apply-templates select="@*"/&gt; &lt;xsl:if test="preceding-sibling::* and not(@*)"&gt; &lt;xsl:text&gt;;&lt;/xsl:text&gt; &lt;/xsl:if&gt; &lt;xsl:value-of select="."/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>Output</strong></p> <pre><code>A;2012-01-01;2012-01-30;Shockwave;Ruby;M1;Nathan|B;2012-01-01;2012-02-30;Other;Erlang;M2;Kristi| </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload