Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT 1.0 text nodes printing by default
    primarykey
    data
    text
    <p>I have looked at <a href="https://stackoverflow.com/questions/3127108/xsl-xsltemplate-match">XSL xsl:template match=&quot;/&quot;</a> but the match pattern that triggered my question is not mentioned there.</p> <p>I have a rather complex XML structure:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;MATERIAL_DATA&gt; &lt;LOG&gt; &lt;USER&gt;Peter&lt;/USER&gt; &lt;DATE&gt;2011-02-18&lt;/DATE&gt; &lt;MATERIALS&gt; &lt;item&gt; &lt;MATNR&gt;636207&lt;/MATNR&gt; &lt;TEXTS&gt; &lt;item&gt; &lt;TEXT&gt;granola bar 40gx24&lt;/TEXT&gt; &lt;/item&gt; &lt;/TEXTS&gt; &lt;PRICES&gt; &lt;item&gt; &lt;MATNR&gt;636207&lt;/MATNR&gt; &lt;COST&gt;125.78&lt;/COST&gt; &lt;/item&gt; &lt;/PRICES&gt; &lt;SALESPRICES&gt; &lt;item&gt; &lt;B01&gt; &lt;MATNR&gt;636207&lt;/MATNR&gt; &lt;CURR&gt;CZK&lt;/CURR&gt; &lt;DATBI&gt;9999-12-31&lt;/DATBI&gt; &lt;DATAB&gt;2010-10-05&lt;/DATAB&gt; &lt;/B01&gt; &lt;B02&gt; &lt;item&gt; &lt;PRICE&gt;477.60&lt;/PRICE&gt; &lt;KUNNR&gt;234567&lt;/KUNNR&gt; &lt;/item&gt; &lt;/B02&gt; &lt;/item&gt; &lt;/SALESPRICES&gt; &lt;/item&gt; &lt;/MATERIALS&gt; &lt;/LOG&gt; &lt;/MATERIAL_DATA&gt; </code></pre> <p>Now if I apply the following XSLT, my output looks correct:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:output method="xml" indent="yes" encoding="UTF-8"/&gt; &lt;xsl:template match="node() | @*"&gt; &lt;xsl:apply-templates select="* | @*" /&gt; &lt;/xsl:template&gt; &lt;xsl:template match="B02"&gt; &lt;xsl:element name="Mi"&gt; &lt;xsl:value-of select="item/KUNNR"/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>I get the output:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Mi&gt;234567&lt;/Mi&gt; </code></pre> <p>But if I apply the XSLT:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:output method="xml" indent="yes" encoding="UTF-8"/&gt; &lt;xsl:template match="/*"&gt; &lt;xsl:element name="MenuItems"&gt; &lt;xsl:apply-templates select="LOG/MATERIALS/item/SALESPRICES/item"/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;xsl:template match="B02"&gt; &lt;xsl:element name="Mi"&gt; &lt;xsl:value-of select="item/KUNNR"/&gt; &lt;/xsl:element&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>the output looks like this:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;MenuItems&gt; 636207 CZK 9999-12-31 2010-10-05 &lt;Mi&gt;234567&lt;/Mi&gt; &lt;/MenuItems&gt; </code></pre> <p>All values from the element <code>&lt;B01&gt;</code> are in the output! But why - I am not matching <code>&lt;B01&gt;</code>!? How does </p> <pre><code>&lt;xsl:template match="node() | @*"&gt; &lt;xsl:apply-templates select="* | @*" /&gt; &lt;/xsl:template&gt; </code></pre> <p>make the output come out correctly? All I am doing with this is match all nodes or attributes and apply-templates to everything or all attributes. But in my opinion it should not make a difference to when I exactly match <code>&lt;B01&gt;</code>! Does anyone have a clue why this is happening?</p> <p>Thank you for your understanding and your hints!</p> <p>Best regards, Peter</p>
    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.
 

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