Templ-EXPORTXML.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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="_EXPORTXML">
  5. <title>#EXPORTXML</title>
  6. <para><emphasis role="bold">#EXPORTXML<indexterm>
  7. <primary>#EXPORTXML</primary>
  8. </indexterm>( </emphasis><emphasis>symbol, data</emphasis> <emphasis
  9. role="bold">);</emphasis></para>
  10. <para><informaltable colsep="1" frame="all" rowsep="1">
  11. <tgroup cols="2">
  12. <colspec colwidth="76.35pt" />
  13. <colspec />
  14. <tbody>
  15. <row>
  16. <entry><emphasis>symbol</emphasis></entry>
  17. <entry>The name of a template variable that has not been
  18. previously declared.</entry>
  19. </row>
  20. <row>
  21. <entry><emphasis>data</emphasis></entry>
  22. <entry>The name of a field, RECORD structure, or dataset.</entry>
  23. </row>
  24. </tbody>
  25. </tgroup>
  26. </informaltable></para>
  27. <para>The <emphasis role="bold">#EXPORTXML </emphasis>statement produces the
  28. same XML as #EXPORT from the specified <emphasis>data</emphasis> and places
  29. it in the <emphasis>symbol</emphasis>, then does a LOADXML(<emphasis>symbol,
  30. </emphasis>‘label') on the data.</para>
  31. <para>Example:</para>
  32. <programlisting> NamesRecord := RECORD
  33. STRING10 first;
  34. STRING20 last;
  35. END;
  36. r := RECORD
  37. UNSIGNED4 dg_parentid;
  38. STRING10 dg_firstname;
  39. STRING dg_lastname;
  40. UNSIGNED1 dg_prange;
  41. IFBLOCK(SELF.dg_prange % 2 = 0)
  42. STRING20 extrafield;
  43. END;
  44. NamesRecord namerec;
  45. DATASET(NamesRecord) childNames;
  46. END;
  47. ds := DATASET('~RTTEST::OUT::ds', r, THOR);
  48. //This example produces the same result as the example for #EXPORT.
  49. //Notice the lack of #DECLARE and LOADXML in this version:
  50. #EXPORTXML(Fred,r);
  51. #FOR (Fred)
  52. #FOR (Field)
  53. #IF (%'{@isEnd}'% &lt;&gt; '')
  54. OUTPUT('END');
  55. #ELSE
  56. OUTPUT(%'{@type}'%
  57. #IF (%'{@size}'% &lt;&gt; '-15' AND
  58. %'{@isRecord}'%='' AND
  59. %'{@isDataset}'%='')
  60. + %'{@size}'%
  61. #END
  62. + ' ' + %'{@label}'% + ';');
  63. #END
  64. #END
  65. #END
  66. OUTPUT('Done');
  67. //**********************************************************
  68. //These examples show some other possible uses of #EXPORTXML:
  69. //This could be greatly simplified as
  70. // (%'{IsAStringMetaInfo/Field[1]/@type}'%='string')
  71. isAString(inputField) := MACRO
  72. #EXPORTXML(IsAStringMetaInfo, inputField);
  73. #IF (%'IsAString'%='')
  74. #DECLARE(IsAString);
  75. #END;
  76. #SET(IsAString, false);
  77. #FOR (IsAStringMetaInfo)
  78. #FOR (Field)
  79. #IF (%'{@type}'% = 'string')
  80. #SET (IsAString, true);
  81. #END
  82. #BREAK
  83. #END
  84. #END
  85. %IsAString%
  86. ENDMACRO;
  87. getFieldName(inputField) := MACRO
  88. #EXPORTXML(GetFieldNameMetaInfo, inputField);
  89. %'{GetFieldNameMetaInfo/Field[1]/@name}'%
  90. ENDMACRO;
  91. displayIsAString(inputField) := MACRO
  92. OUTPUT(getFieldName(inputField)
  93. + TRIM(IF(isAString(inputField), ' is', ' is not'))
  94. + ' a string.')
  95. ENDMACRO;
  96. SIZEOF(r.dg_firstname);
  97. isAString(r.dg_firstname);
  98. getFieldName(r.dg_firstname);
  99. OUTPUT('ds.dg_firstname isAString? '
  100. + (STRING)isAString(ds.dg_firstname));
  101. isAString(ds.namerec);
  102. displayIsAString(ds.namerec);
  103. displayIsAString(r.dg_firstname);
  104. </programlisting>
  105. <para>See Also: <link linkend="LOADXML">LOADXML</link>, <link
  106. linkend="_EXPORT">#EXPORT</link></para>
  107. </sect1>