Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>I would use keys -- both for convenience and efficiency</strong>:</p> <pre><code>key('kPlaysByAuthor', 'Shakespeare, William') </code></pre> <p><strong>To select just the <code>playcode</code>:</strong></p> <pre><code>key('kPlaysByAuthor', 'Shakespeare, William')/playcode </code></pre> <p><strong>Here is a complete example</strong>:</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="kPlaysByAuthor" match="edition" use="metadataBlock/meta[@name='Creator']/@content"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:copy-of select= "key('kPlaysByAuthor', 'Shakespeare, William')/playcode"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when this transformation is applied on the following XML document:</strong></p> <pre><code>&lt;works&gt; &lt;editions&gt; &lt;edition&gt; &lt;playtitle&gt;Henry IV, Part 1&lt;/playtitle&gt; &lt;playcode&gt;1H4&lt;/playcode&gt; &lt;genre&gt;play&lt;/genre&gt; &lt;metadataBlock&gt; &lt;meta content="Shakespeare, William" name="Creator"/&gt; &lt;/metadataBlock&gt; &lt;/edition&gt; &lt;edition&gt; &lt;playtitle&gt;Some Title&lt;/playtitle&gt; &lt;playcode&gt;XYZ&lt;/playcode&gt; &lt;genre&gt;play&lt;/genre&gt; &lt;metadataBlock&gt; &lt;meta content="Someone, Else" name="Creator"/&gt; &lt;/metadataBlock&gt; &lt;/edition&gt; &lt;/editions&gt; &lt;/works&gt; </code></pre> <p><strong>the wanted, correct result is produced</strong>:</p> <pre><code>&lt;playcode&gt;1H4&lt;/playcode&gt; </code></pre>
 

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