Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that the context changes in your <code>analyze-string</code> element. Maybe the following solution will help you.</p> <p>For an XML file like that : </p> <pre><code>&lt;a&gt; &lt;Format&gt; &lt;TagNr&gt;92&lt;/TagNr&gt; &lt;Option&gt;A&lt;/Option&gt; &lt;Format&gt;//[N]15d&lt;/Format&gt; &lt;/Format&gt; &lt;Format&gt; &lt;TagNr&gt;92&lt;/TagNr&gt; &lt;Option&gt;B&lt;/Option&gt; &lt;Format&gt;//3!a/3!a/15d&lt;/Format&gt; &lt;/Format&gt; &lt;Tag&gt; &lt;TagNr&gt;92&lt;/TagNr&gt; &lt;Options&gt;AB&lt;/Options&gt; &lt;/Tag&gt; &lt;/a&gt; </code></pre> <p>Consider the following 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" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"&gt; &lt;xsl:output indent="yes"/&gt; &lt;xsl:key name="xx" match="//Format/Format" use="concat(../TagNr, ../Option)"/&gt; &lt;xsl:template match="/"&gt; &lt;result&gt; &lt;xsl:apply-templates select="//Tag"/&gt; &lt;/result&gt; &lt;/xsl:template&gt; &lt;xsl:template match="Tag"&gt; &lt;xsl:call-template name="createOPT"&gt; &lt;xsl:with-param name="str" as="xs:string" select="Options"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:template&gt; &lt;xsl:template name="createOPT"&gt; &lt;xsl:param name="str"/&gt; &lt;xsl:if test="string-length($str) &gt; 0"&gt; &lt;xsl:variable name="firstChar" select="substring($str,1,1)"/&gt; &lt;xsl:variable name="TNO" select="concat(TagNr,$firstChar)"/&gt; &lt;opt&gt; &lt;tag&gt;&lt;xsl:value-of select="$TNO"/&gt;&lt;/tag&gt; &lt;fmt&gt;&lt;xsl:value-of select="key('xx', $TNO)"/&gt;&lt;/fmt&gt; &lt;/opt&gt; &lt;xsl:call-template name="createOPT"&gt; &lt;xsl:with-param name="str" select="substring($str,2)"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>The result is : </p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;result&gt; &lt;opt&gt; &lt;tag&gt;92A&lt;/tag&gt; &lt;fmt&gt;//[N]15d&lt;/fmt&gt; &lt;/opt&gt; &lt;opt&gt; &lt;tag&gt;92B&lt;/tag&gt; &lt;fmt&gt;//3!a/3!a/15d&lt;/fmt&gt; &lt;/opt&gt; &lt;/result&gt; </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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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