Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Use</strong>:</p> <pre><code>//page[@id=$yourId]/node()[not(self::page)] </code></pre> <p>This selects all nodes that are not <code>page</code> and that are children of any <code>page</code> in the document, the string value of whose <code>id</code> attribute is equal to the string contained in <code>$yourId</code> (most probably you would substitute <code>$yourId</code> above with a specific, desired string, such as <code>'1'</code>).</p> <p><strong>Here is a simple XSLT-based verification</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:param name="pId" select="3"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:copy-of select="//page[@id=$pId]/node()[not(self::page)]"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>when this transformation is applied on the provided XML document</strong> (wrapped in a single top node to make it well-formed):</p> <pre><code>&lt;pages&gt; &lt;page id='1'&gt; &lt;title&gt;Page 1&lt;/title&gt; &lt;page id='2'&gt; &lt;title&gt;Sub Page 1&lt;/title&gt; &lt;/page&gt; &lt;page id='3'&gt; &lt;title&gt;Sub Page 2&lt;/title&gt; &lt;/page&gt; &lt;/page&gt; &lt;page id='4'&gt; &lt;title&gt;Page 2&lt;/title&gt; &lt;/page&gt; &lt;/pages&gt; </code></pre> <p><strong>the wanted, correct result is produced</strong>:</p> <pre><code>&lt;title&gt;Sub Page 2&lt;/title&gt; </code></pre> <p><strong>Do note</strong>: One assumption made is that an <code>id</code> value uniquely identifies a <code>page</code>. If this is not so, the proposed XPath expression will select <em>all</em> <code>page</code> elements whose <code>id</code> attribute has a string valu of <code>$yourId</code>.</p> <p>If this is the case and only one <code>page</code> element must be selected, the OP must specify which one of the many <code>page</code> elements with this <code>id</code> should be selected.</p> <p><strong>For example, it may be the first</strong>:</p> <pre><code>(//page[@id=$yourId]/node()[not(self::page)])[1] </code></pre> <p><strong>or the last</strong>:</p> <pre><code>(//page[@id=$yourId]/node()[not(self::page)])[last()] </code></pre> <p><strong>or ...</strong></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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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