GetXMLParseTree.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
  4. <sect1 id="GetXMLParseTree">
  5. <title>GetXMLParseTree</title>
  6. <para><emphasis role="bold">STD.System.Debug.GetXMLParseTree<indexterm>
  7. <primary>STD.System.Debug.GetXMLParseTree</primary>
  8. </indexterm> <indexterm>
  9. <primary>System.Debug.GetXMLParseTree</primary>
  10. </indexterm> <indexterm>
  11. <primary>Debug.GetXMLParseTree</primary>
  12. </indexterm> <indexterm>
  13. <primary>GetXMLParseTree</primary>
  14. </indexterm>(</emphasis> <emphasis> </emphasis> <emphasis
  15. role="bold">)</emphasis></para>
  16. <informaltable colsep="0" frame="none" rowsep="0">
  17. <tgroup cols="2">
  18. <colspec colwidth="80.50pt" />
  19. <colspec />
  20. <tbody>
  21. <row>
  22. <entry>Return:<emphasis> </emphasis></entry>
  23. <entry>GetXMLParseTree returns a STRING value.</entry>
  24. </row>
  25. </tbody>
  26. </tgroup>
  27. </informaltable>
  28. <para>The <emphasis role="bold">GetXMLParseTree </emphasis>function returns
  29. a textual representation of the match that occurred, using XML tags to
  30. indicate nesting. This function is only used within the RECORD or TRANSFORM
  31. structure that defines the result of a PARSE operation. This function is
  32. useful for debugging PARSE operations.</para>
  33. <para>Example:</para>
  34. <programlisting format="linespecific">IMPORT STD;
  35. r := {string150 line};
  36. d := dataset([
  37. {'Ge 34:2 And when Shechem the son of Hamor the Hivite, '+
  38. 'prince of the country, saw her, he took her, and lay with her, '+
  39. 'and defiled her.'},
  40. {'Ge 36:10 These are the names of Esaus sons; Eliphaz the son of '+
  41. 'Adah the wife of Esau, Reuel the son of Bashemath the wife of '+
  42. 'Esau.'}
  43. ],r);
  44. PATTERN ws := [' ','\t',',']*;
  45. PATTERN patStart := FIRST | ws;
  46. PATTERN patEnd := LAST | ws;
  47. PATTERN article := ['A','The','Thou','a','the','thou'];
  48. TOKEN patWord := PATTERN('[a-zA-Z]+');
  49. TOKEN Name := PATTERN('[A-Z][a-zA-Z]+');
  50. RULE Namet := name OPT(ws 'the' ws name);
  51. PATTERN produced_by := OPT(article ws) ['son of','daughter of'];
  52. PATTERN produces_with := OPT(article ws) ['wife of'];
  53. RULE progeny := namet ws ( produced_by | produces_with ) ws namet;
  54. results := RECORD
  55. STRING LeftName := MATCHTEXT(Namet[1]);
  56. STRING RightName := MATCHTEXT(Namet[2]);
  57. STRING LinkPhrase := IF(MATCHTEXT(produced_by[1])&lt;&gt;'',
  58. MATCHTEXT(produced_by[1]),
  59. MATCHTEXT(produces_with[1]));
  60. STRING Tree := STD.System.Debug.getXMLParseTree();
  61. END;
  62. outfile1 := PARSE(d,line,progeny,results,SCAN ALL);
  63. /* the Tree field output
  64. looks like this:
  65. &lt;namet&gt;
  66. &lt;name&gt;Shechem&lt;/name&gt;
  67. &lt;/namet&gt;
  68. &lt;ws&gt; &lt;/ws&gt;
  69. &lt;produced_by&gt;the son of&lt;/produced_by&gt;
  70. &lt;ws&gt; &lt;/ws&gt;
  71. &lt;namet&gt;
  72. &lt;name&gt;Hamor&lt;/name&gt;
  73. &lt;/namet&gt;
  74. */
  75. </programlisting>
  76. </sect1>