Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>The short answer is negative</strong>.</p> <p>There is nothing "procedural" in a multidimensional array. Simply, XPath is a query (navigational) language for tree structures (XML documents) and tree structures have almost nothing in common with mutlti-dimensional arrays.</p> <p><strong>Tree structures are just 2-dimensional</strong>.</p> <p>This said, one can build analogies (models) to multi-dimensional objects:</p> <pre><code>&lt;t&gt; &lt;a&gt; &lt;b&gt; &lt;c&gt;11&lt;/c&gt; &lt;c&gt;12&lt;/c&gt; &lt;c&gt;13&lt;/c&gt; &lt;c&gt;14&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;15&lt;/c&gt; &lt;c&gt;16&lt;/c&gt; &lt;c&gt;17&lt;/c&gt; &lt;c&gt;18&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;19&lt;/c&gt; &lt;c&gt;20&lt;/c&gt; &lt;c&gt;21&lt;/c&gt; &lt;c&gt;22&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;23&lt;/c&gt; &lt;c&gt;24&lt;/c&gt; &lt;c&gt;25&lt;/c&gt; &lt;c&gt;26&lt;/c&gt; &lt;/b&gt; &lt;/a&gt; &lt;a&gt; &lt;b&gt; &lt;c&gt;27&lt;/c&gt; &lt;c&gt;28&lt;/c&gt; &lt;c&gt;29&lt;/c&gt; &lt;c&gt;30&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;31&lt;/c&gt; &lt;c&gt;32&lt;/c&gt; &lt;c&gt;33&lt;/c&gt; &lt;c&gt;34&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;35&lt;/c&gt; &lt;c&gt;36&lt;/c&gt; &lt;c&gt;37&lt;/c&gt; &lt;c&gt;38&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;39&lt;/c&gt; &lt;c&gt;40&lt;/c&gt; &lt;c&gt;41&lt;/c&gt; &lt;c&gt;42&lt;/c&gt; &lt;/b&gt; &lt;/a&gt; &lt;a&gt; &lt;b&gt; &lt;c&gt;43&lt;/c&gt; &lt;c&gt;44&lt;/c&gt; &lt;c&gt;45&lt;/c&gt; &lt;c&gt;46&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;47&lt;/c&gt; &lt;c&gt;48&lt;/c&gt; &lt;c&gt;49&lt;/c&gt; &lt;c&gt;50&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;51&lt;/c&gt; &lt;c&gt;52&lt;/c&gt; &lt;c&gt;53&lt;/c&gt; &lt;c&gt;54&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;55&lt;/c&gt; &lt;c&gt;56&lt;/c&gt; &lt;c&gt;57&lt;/c&gt; &lt;c&gt;58&lt;/c&gt; &lt;/b&gt; &lt;/a&gt; &lt;a&gt; &lt;b&gt; &lt;c&gt;59&lt;/c&gt; &lt;c&gt;60&lt;/c&gt; &lt;c&gt;61&lt;/c&gt; &lt;c&gt;62&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;63&lt;/c&gt; &lt;c&gt;64&lt;/c&gt; &lt;c&gt;65&lt;/c&gt; &lt;c&gt;66&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;67&lt;/c&gt; &lt;c&gt;68&lt;/c&gt; &lt;c&gt;69&lt;/c&gt; &lt;c&gt;70&lt;/c&gt; &lt;/b&gt; &lt;b&gt; &lt;c&gt;71&lt;/c&gt; &lt;c&gt;72&lt;/c&gt; &lt;c&gt;73&lt;/c&gt; &lt;c&gt;74&lt;/c&gt; &lt;/b&gt; &lt;/a&gt; &lt;/t&gt; </code></pre> <p><strong>When we evaluate against the XML document above this XPath expression</strong>:</p> <pre><code>/*/a[4]/*[4]/*[4] </code></pre> <p><strong>the selected node is</strong>:</p> <pre><code>&lt;c&gt;74&lt;/c&gt; </code></pre> <p><strong>A complete XSLT transformation example, using such XPath expression</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:template match="/*"&gt; &lt;xsl:value-of select="a[4]/*[4]/*[4]"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>when this transformation is applied on the XML document above, the wanted, correct result is produced:</p> <pre><code>74 </code></pre> <p><strong>Update</strong>: The OP has revealed in a comment that he needs the multidimensional array capability in order to implement a general parsing algorithm in XSLT.</p> <p>I would advise to try to implement a simpler and more efficient parsing algorithm, such as LALR(1) parsing.</p> <p><strong>Here are some advantages LALR(1) parsers</strong>:</p> <ol> <li>An LALR parser can be automatically generated from an LALR grammar.</li> <li>An LALR grammar can be used to define many computer languages.</li> <li>An LALR parser is small.</li> <li>An LALR parser is fast (if the parsing algorithm uses a matrix parser-table format).</li> <li>An LALR parser is linear in speed (i.e. the speed is based on the size of the input text file only and not based on the size of the language being recognized).</li> <li>The LALR grammar provides valuable documentation of the language being recognized.</li> <li>Error recovery may already be built-in to the parser.</li> <li>Generalized error messages may already be built into the parser.</li> <li>Abstract-syntax-tree construction may already be built into the parser.</li> <li>Recognition of context-sensitive language constructs may already be built into the parser.</li> </ol> <p><strong><a href="http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/func-lrParse.xsl?view=markup" rel="nofollow">A general LALR(1) parser is already implemented in pure XSLT 2.0</a> and is part of <a href="http://fxsl.sf.net" rel="nofollow">FXSL</a></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. 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