Note that there are some explanatory texts on larger screens.

plurals
  1. POXML complex Pattern-Matching expressions
    primarykey
    data
    text
    <p>I need to match patterns on a set of XML documents (all with the same schema), and when a pattern matches, I need to retrieve the content and do some specific transformations on it.</p> <p>I have a list of those "patterns", that are similar to regular expressions, but with elements and attributes. </p> <p>pseudo-pattern example:</p> <pre><code>(//ELEMENTx) (node())* (//ELEMENTy[@ATTRIBUTEz]) (node())* (//@ATTRIBUTEw) </code></pre> <p>I used XPath syntax inside the parenthesis only. Other quantifiers could be used...</p> <p>This would match when the xml has ELEMENTx as the first element, ends with one element that has ATTRIBUTEw, and in between needs to have an ELEMENTy with ATTRIBUTEz. </p> <p>Note that I need to match the whole document for each whole pattern, not just part of it.</p> <p>The nesting of elements does not matter in this case (ELEMENTy could be a child of ELEMENTx, or not), but they need to have that specific order.</p> <p>EDIT: To clarify, the XML have trees with syntactic information. I need to match syntactic patterns. </p> <p>Example:</p> <pre> TOP / \ X Y |\ |\ 1 2 3 4 </pre> <p>Matching patterns could be (node names, assuming no attributes):<br> X Y<br> 1 * Y<br> X 3 4<br> 1 * 4 </p> <hr> <p>I could use XPath to get each individual part of the pattern, but then I loose the sense of order...if I do two XPath queries, I don't know the positions of the results relative to each other.</p> <p>After matching, I will have rules for each pattern, that specify some transformations on the content (change order etc).</p> <p>Is there any way to do something like this using XPath or XQuery? I could use DOM and make the pattern matching code myself, but maybe there is already a better way to do this.</p> <p>Thanks for any pointers.</p>
    singulars
    1. This table or related slice is empty.
    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