Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Two solutions:</p> <p><strong>Solution1</strong> (no keys):</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:template match= "vo/field[@name=../../update/*/*/@name]"&gt; &lt;xsl:value-of select="concat(@name,' ',@type,'&amp;#xA;')"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When applied on the provided XML document</strong> (corrected to be made well-formed):</p> <pre><code>&lt;t&gt; &lt;vo class="GroupEntry" buildByAlias="true"&gt; &lt;objectClass name="groupOfNames"/&gt; &lt;field name="commonName" nameLDAP="cn" type="String"/&gt; &lt;field name="description" nameLDAP="description" type="String"/&gt; &lt;field name="member" nameLDAP="member" type="String[]"/&gt; &lt;/vo&gt; &lt;update method="addMember" modificationMode="ADD_ATTRIBUTE"&gt; &lt;input&gt; &lt;field name="member"/&gt; &lt;field name="description"/&gt; &lt;/input&gt; &lt;/update&gt; &lt;/t&gt; </code></pre> <p><strong>the wanted, correct result is produced</strong>:</p> <pre><code>description String member String[] </code></pre> <p><strong>Solution2</strong> (using a key):</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:key name="kFieldByName" match="vo/field" use="@name"/&gt; &lt;xsl:template match="/*"&gt; &lt;xsl:apply-templates mode="selected" select= "key('kFieldByName', update/*/*/@name)"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="vo/field" mode="selected"&gt; &lt;xsl:value-of select="concat(@name,' ',@type,'&amp;#xA;')"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when applied on the same XML document (above), the same correct result is produced</strong>:</p> <pre><code>description String member String[] </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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