Note that there are some explanatory texts on larger screens.

plurals
  1. POXSLT 2.0 Xpath error "not a node item"
    primarykey
    data
    text
    <p>my first post here - sure hope someone will know the answer! I have been able to find solutions for many issues I had, but not for this one. The questions and answers on this site on the same subject did not solve my issue...</p> <p>I have an xml containing Format specifications like</p> <pre><code>&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; </code></pre> <p>TagNr + option is a unique combination within this nodeset.</p> <p>I defined a key to make using the set of formats easier:</p> <pre><code>&lt;xsl:key name="xx" match="//Format/Format" use="concat(../TagNr, ../Option)"/&gt; </code></pre> <p>I can indeed use this key and get the correct value, but only in non-special elements; I get an error "Error in XPath 2.0 expression Not a node item" when using this key within for-each or other constructs like the one below.</p> <p>What I try to achieve is the following: In other nodes processed there is a string of options for which I wish to retrieve the format for each character. For example:</p> <pre><code>&lt;Tag&gt; &lt;TagNr&gt;92&lt;/TagNr&gt; &lt;Options&gt;AB&lt;/Options&gt; &lt;/Tag&gt; </code></pre> <p>I have been trying lots of variants of the below but no luck:</p> <pre><code>&lt;xsl:variable name="TN"&gt;&lt;xsl:value-of select="TagNr"/&gt;&lt;/xsl:variable&gt; &lt;xsl:variable name="optList"&gt; &lt;xsl:analyze-string select="./Options" regex="[A-Z]"&gt; &lt;xsl:matching-substring&gt; &lt;xsl:variable name="TNO" select="concat($TN, .)"/&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:matching-substring&gt; &lt;/xsl:analyze-string&gt; &lt;/xsl:variable&gt; </code></pre> <p>Splitting into individual characters using the regex goes fine and when retrieving (only) the value for opt/tag that goes fine too. But when I add opt/fmt, I run into the mentioned error message for the Xpath expression <strong>select="key('xx', $TNO)"</strong>.</p> <p>I tried defining a variable based on the key function as suggested in another thread on this site, but did not succeed.</p> <p>Can anyone help me?</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.
    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