1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 1999 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xalan" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, Lotus
  53. * Development Corporation., http://www.lotus.com. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package org.apache.xalan.processor;
  58. import java.util.Hashtable;
  59. import org.apache.xalan.templates.*;
  60. import org.apache.xml.utils.QName;
  61. /**
  62. * This class defines the allowed structure for a stylesheet, and the
  63. * mapping between Xalan classes and the markup elements in the stylesheet.
  64. * @see <a href="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
  65. */
  66. public class XSLTSchema extends XSLTElementDef
  67. {
  68. /**
  69. * Construct a XSLTSchema which represents the XSLT "schema".
  70. */
  71. XSLTSchema()
  72. {
  73. build();
  74. }
  75. /**
  76. * This method builds an XSLT "schema" according to http://www.w3.org/TR/xslt#dtd. This
  77. * schema provides instructions for building the Xalan Stylesheet (Templates) structure.
  78. */
  79. void build()
  80. {
  81. // xsl:import, xsl:include
  82. XSLTAttributeDef hrefAttr = new XSLTAttributeDef(null, "href",
  83. XSLTAttributeDef.T_URL, true, false,XSLTAttributeDef.ERROR);
  84. // xsl:preserve-space, xsl:strip-space
  85. XSLTAttributeDef elementsAttr = new XSLTAttributeDef(null, "elements",
  86. XSLTAttributeDef.T_SIMPLEPATTERNLIST,
  87. true, false, XSLTAttributeDef.ERROR);
  88. // XSLTAttributeDef anyNamespacedAttr = new XSLTAttributeDef("*", "*",
  89. // XSLTAttributeDef.T_CDATA, false);
  90. // xsl:output
  91. XSLTAttributeDef methodAttr = new XSLTAttributeDef(null, "method",
  92. XSLTAttributeDef.T_QNAME, false, false,XSLTAttributeDef.ERROR);
  93. XSLTAttributeDef versionAttr = new XSLTAttributeDef(null, "version",
  94. XSLTAttributeDef.T_NMTOKEN, false, false,XSLTAttributeDef.ERROR);
  95. XSLTAttributeDef encodingAttr = new XSLTAttributeDef(null, "encoding",
  96. XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
  97. XSLTAttributeDef omitXmlDeclarationAttr = new XSLTAttributeDef(null,
  98. "omit-xml-declaration",
  99. XSLTAttributeDef.T_YESNO,
  100. false, false,XSLTAttributeDef.ERROR);
  101. XSLTAttributeDef standaloneAttr = new XSLTAttributeDef(null,
  102. "standalone",
  103. XSLTAttributeDef.T_YESNO, false, false,XSLTAttributeDef.ERROR);
  104. XSLTAttributeDef doctypePublicAttr = new XSLTAttributeDef(null,
  105. "doctype-public",
  106. XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
  107. XSLTAttributeDef doctypeSystemAttr = new XSLTAttributeDef(null,
  108. "doctype-system",
  109. XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
  110. XSLTAttributeDef cdataSectionElementsAttr = new XSLTAttributeDef(null,
  111. "cdata-section-elements",
  112. XSLTAttributeDef.T_QNAMES_RESOLVE_NULL,
  113. false, false,XSLTAttributeDef.ERROR);
  114. XSLTAttributeDef indentAttr = new XSLTAttributeDef(null, "indent",
  115. XSLTAttributeDef.T_YESNO, false, false,XSLTAttributeDef.ERROR);
  116. XSLTAttributeDef mediaTypeAttr = new XSLTAttributeDef(null, "media-type",
  117. XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.ERROR);
  118. // Required.
  119. // It is an error if the name attribute is invalid on any of these elements
  120. // xsl:key, xsl:attribute-set, xsl:call-template, xsl:with-param, xsl:variable, xsl:param
  121. XSLTAttributeDef nameAttrRequired = new XSLTAttributeDef(null, "name",
  122. XSLTAttributeDef.T_QNAME, true, false,XSLTAttributeDef.ERROR);
  123. // Required.
  124. // Support AVT
  125. // xsl:element, xsl:attribute
  126. XSLTAttributeDef nameAVTRequired = new XSLTAttributeDef(null, "name",
  127. XSLTAttributeDef.T_AVT_QNAME, true, true,XSLTAttributeDef.WARNING);
  128. // Required.
  129. // Support AVT
  130. // xsl:processing-instruction
  131. XSLTAttributeDef nameAVT_NCNAMERequired = new XSLTAttributeDef(null, "name",
  132. XSLTAttributeDef.T_NCNAME, true, true,XSLTAttributeDef.WARNING);
  133. // Optional.
  134. // Static error if invalid
  135. // xsl:template, xsl:decimal-format
  136. XSLTAttributeDef nameAttrOpt_ERROR = new XSLTAttributeDef(null, "name",
  137. XSLTAttributeDef.T_QNAME, false, false,XSLTAttributeDef.ERROR);
  138. // xsl:key
  139. XSLTAttributeDef useAttr = new XSLTAttributeDef(null, "use",
  140. XSLTAttributeDef.T_EXPR, true, false,XSLTAttributeDef.ERROR);
  141. // xsl:element, xsl:attribute
  142. XSLTAttributeDef namespaceAVTOpt = new XSLTAttributeDef(null,
  143. "namespace",XSLTAttributeDef.T_URL,
  144. false, true,XSLTAttributeDef.WARNING);
  145. // xsl:decimal-format
  146. XSLTAttributeDef decimalSeparatorAttr = new XSLTAttributeDef(null,
  147. "decimal-separator",
  148. XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, ".");
  149. XSLTAttributeDef infinityAttr = new XSLTAttributeDef(null, "infinity",
  150. XSLTAttributeDef.T_CDATA, false,XSLTAttributeDef.ERROR,"Infinity");
  151. XSLTAttributeDef minusSignAttr = new XSLTAttributeDef(null, "minus-sign",
  152. XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR,"-");
  153. XSLTAttributeDef NaNAttr = new XSLTAttributeDef(null, "NaN",
  154. XSLTAttributeDef.T_CDATA, false,XSLTAttributeDef.ERROR, "NaN");
  155. XSLTAttributeDef percentAttr = new XSLTAttributeDef(null, "percent",
  156. XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, "%");
  157. XSLTAttributeDef perMilleAttr = new XSLTAttributeDef(null, "per-mille",
  158. XSLTAttributeDef.T_CHAR,
  159. false, false,XSLTAttributeDef.ERROR /* ,"‰" */);
  160. XSLTAttributeDef zeroDigitAttr = new XSLTAttributeDef(null, "zero-digit",
  161. XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, "0");
  162. XSLTAttributeDef digitAttr = new XSLTAttributeDef(null, "digit",
  163. XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, "#");
  164. XSLTAttributeDef patternSeparatorAttr = new XSLTAttributeDef(null,
  165. "pattern-separator",
  166. XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR, ";");
  167. // xsl:decimal-format
  168. XSLTAttributeDef groupingSeparatorAttr = new XSLTAttributeDef(null,
  169. "grouping-separator",
  170. XSLTAttributeDef.T_CHAR, false,XSLTAttributeDef.ERROR,",");
  171. // xsl:element, xsl:attribute-set, xsl:copy
  172. XSLTAttributeDef useAttributeSetsAttr = new XSLTAttributeDef(null,
  173. "use-attribute-sets",
  174. XSLTAttributeDef.T_QNAMES,
  175. false, false, XSLTAttributeDef.ERROR);
  176. // xsl:if, xsl:when
  177. XSLTAttributeDef testAttrRequired = new XSLTAttributeDef(null, "test",
  178. XSLTAttributeDef.T_EXPR, true, false,XSLTAttributeDef.ERROR);
  179. // Required.
  180. // xsl:value-of, xsl:for-each, xsl:copy-of
  181. XSLTAttributeDef selectAttrRequired = new XSLTAttributeDef(null,
  182. "select",
  183. XSLTAttributeDef.T_EXPR, true, false,XSLTAttributeDef.ERROR);
  184. // Optional.
  185. // xsl:variable, xsl:param, xsl:with-param
  186. XSLTAttributeDef selectAttrOpt = new XSLTAttributeDef(null, "select",
  187. XSLTAttributeDef.T_EXPR, false, false,XSLTAttributeDef.ERROR);
  188. // Optional.
  189. // Default: "node()"
  190. // xsl:apply-templates
  191. XSLTAttributeDef selectAttrDefNode = new XSLTAttributeDef(null, "select",
  192. XSLTAttributeDef.T_EXPR, false,XSLTAttributeDef.ERROR, "node()");
  193. // Optional.
  194. // Default: "."
  195. // xsl:sort
  196. XSLTAttributeDef selectAttrDefDot = new XSLTAttributeDef(null, "select",
  197. XSLTAttributeDef.T_EXPR, false,XSLTAttributeDef.ERROR, ".");
  198. // xsl:key
  199. XSLTAttributeDef matchAttrRequired = new XSLTAttributeDef(null, "match",
  200. XSLTAttributeDef.T_PATTERN, true, false,XSLTAttributeDef.ERROR);
  201. // xsl:template
  202. XSLTAttributeDef matchAttrOpt = new XSLTAttributeDef(null, "match",
  203. XSLTAttributeDef.T_PATTERN, false, false,XSLTAttributeDef.ERROR);
  204. // xsl:template
  205. XSLTAttributeDef priorityAttr = new XSLTAttributeDef(null, "priority",
  206. XSLTAttributeDef.T_NUMBER, false, false,XSLTAttributeDef.ERROR);
  207. // xsl:template, xsl:apply-templates
  208. XSLTAttributeDef modeAttr = new XSLTAttributeDef(null, "mode",
  209. XSLTAttributeDef.T_QNAME, false, false,XSLTAttributeDef.ERROR);
  210. XSLTAttributeDef spaceAttr =
  211. new XSLTAttributeDef(Constants.S_XMLNAMESPACEURI, "space", false, false, false, XSLTAttributeDef.WARNING,
  212. "default", Constants.ATTRVAL_STRIP, "preserve",
  213. Constants.ATTRVAL_PRESERVE);
  214. XSLTAttributeDef spaceAttrLiteral =
  215. new XSLTAttributeDef(Constants.S_XMLNAMESPACEURI, "space",
  216. XSLTAttributeDef.T_URL, false, true,XSLTAttributeDef.ERROR);
  217. // xsl:namespace-alias
  218. XSLTAttributeDef stylesheetPrefixAttr = new XSLTAttributeDef(null,
  219. "stylesheet-prefix",
  220. XSLTAttributeDef.T_CDATA, true, false,XSLTAttributeDef.ERROR);
  221. XSLTAttributeDef resultPrefixAttr = new XSLTAttributeDef(null,
  222. "result-prefix",
  223. XSLTAttributeDef.T_CDATA, true, false,XSLTAttributeDef.ERROR);
  224. // xsl:text, xsl:value-of
  225. XSLTAttributeDef disableOutputEscapingAttr = new XSLTAttributeDef(null,
  226. "disable-output-escaping",
  227. XSLTAttributeDef.T_YESNO,
  228. false, false,XSLTAttributeDef.ERROR);
  229. // xsl:number
  230. XSLTAttributeDef levelAttr = new XSLTAttributeDef(null, "level", false, false, false, XSLTAttributeDef.ERROR,
  231. "single", Constants.NUMBERLEVEL_SINGLE,
  232. "multiple", Constants.NUMBERLEVEL_MULTI,
  233. "any", Constants.NUMBERLEVEL_ANY);
  234. levelAttr.setDefault("single");
  235. XSLTAttributeDef countAttr = new XSLTAttributeDef(null, "count",
  236. XSLTAttributeDef.T_PATTERN, false, false,XSLTAttributeDef.ERROR);
  237. XSLTAttributeDef fromAttr = new XSLTAttributeDef(null, "from",
  238. XSLTAttributeDef.T_PATTERN, false, false,XSLTAttributeDef.ERROR);
  239. XSLTAttributeDef valueAttr = new XSLTAttributeDef(null, "value",
  240. XSLTAttributeDef.T_EXPR, false, false,XSLTAttributeDef.ERROR);
  241. XSLTAttributeDef formatAttr = new XSLTAttributeDef(null, "format",
  242. XSLTAttributeDef.T_CDATA, false, true,XSLTAttributeDef.ERROR);
  243. formatAttr.setDefault("1");
  244. // xsl:number, xsl:sort
  245. XSLTAttributeDef langAttr = new XSLTAttributeDef(null, "lang",
  246. XSLTAttributeDef.T_NMTOKEN, false, true,XSLTAttributeDef.ERROR);
  247. // xsl:number
  248. XSLTAttributeDef letterValueAttr = new XSLTAttributeDef(null,
  249. "letter-value",
  250. false, true, false, XSLTAttributeDef.ERROR,
  251. "alphabetic", Constants.NUMBERLETTER_ALPHABETIC,
  252. "traditional", Constants.NUMBERLETTER_TRADITIONAL);
  253. // xsl:number
  254. XSLTAttributeDef groupingSeparatorAVT = new XSLTAttributeDef(null,
  255. "grouping-separator",
  256. XSLTAttributeDef.T_CHAR, false, true,XSLTAttributeDef.ERROR);
  257. // xsl:number
  258. XSLTAttributeDef groupingSizeAttr = new XSLTAttributeDef(null,
  259. "grouping-size",
  260. XSLTAttributeDef.T_NUMBER, false, true,XSLTAttributeDef.ERROR);
  261. // xsl:sort
  262. XSLTAttributeDef dataTypeAttr = new XSLTAttributeDef(null, "data-type", false, true, true, XSLTAttributeDef.ERROR,
  263. "text", Constants.SORTDATATYPE_TEXT ,"number", Constants.SORTDATATYPE_TEXT);
  264. dataTypeAttr.setDefault("text");
  265. // xsl:sort
  266. XSLTAttributeDef orderAttr = new XSLTAttributeDef(null, "order", false, true, false,XSLTAttributeDef.ERROR,
  267. "ascending", Constants.SORTORDER_ASCENDING,
  268. "descending", Constants.SORTORDER_DESCENDING);
  269. orderAttr.setDefault("ascending");
  270. // xsl:sort
  271. XSLTAttributeDef caseOrderAttr = new XSLTAttributeDef(null, "case-order", false, true, false,XSLTAttributeDef.ERROR,
  272. "upper-first", Constants.SORTCASEORDER_UPPERFIRST ,
  273. "lower-first", Constants.SORTCASEORDER_LOWERFIRST);
  274. // xsl:message
  275. XSLTAttributeDef terminateAttr = new XSLTAttributeDef(null, "terminate",
  276. XSLTAttributeDef.T_YESNO, false, false,XSLTAttributeDef.ERROR);
  277. terminateAttr.setDefault("no");
  278. // top level attributes
  279. XSLTAttributeDef xslExcludeResultPrefixesAttr =
  280. new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL,
  281. "exclude-result-prefixes",
  282. XSLTAttributeDef.T_STRINGLIST, false, false,XSLTAttributeDef.ERROR);
  283. XSLTAttributeDef xslExtensionElementPrefixesAttr =
  284. new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL,
  285. "extension-element-prefixes",
  286. XSLTAttributeDef.T_PREFIX_URLLIST, false, false,XSLTAttributeDef.ERROR);
  287. // result-element-atts
  288. XSLTAttributeDef xslUseAttributeSetsAttr =
  289. new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL, "use-attribute-sets",
  290. XSLTAttributeDef.T_QNAMES, false, false,XSLTAttributeDef.ERROR);
  291. XSLTAttributeDef xslVersionAttr =
  292. new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL, "version",
  293. XSLTAttributeDef.T_NMTOKEN, false, false,XSLTAttributeDef.ERROR);
  294. XSLTElementDef charData = new XSLTElementDef(this, null, "text()",
  295. null /*alias */, null /* elements */, null, /* attributes */
  296. new ProcessorCharacters(),
  297. ElemTextLiteral.class /* class object */);
  298. charData.setType(XSLTElementDef.T_PCDATA);
  299. XSLTElementDef whiteSpaceOnly = new XSLTElementDef(this, null, "text()",
  300. null /*alias */, null /* elements */,
  301. null, /* attributes */
  302. null,
  303. ElemTextLiteral.class /* should be null? -sb */);
  304. charData.setType(XSLTElementDef.T_PCDATA);
  305. XSLTAttributeDef resultAttr = new XSLTAttributeDef(null, "*",
  306. XSLTAttributeDef.T_AVT, false, true,XSLTAttributeDef.WARNING);
  307. XSLTAttributeDef xslResultAttr =
  308. new XSLTAttributeDef(Constants.S_XSLNAMESPACEURL, "*",
  309. XSLTAttributeDef.T_CDATA, false, false,XSLTAttributeDef.WARNING);
  310. XSLTElementDef[] templateElements = new XSLTElementDef[23];
  311. XSLTElementDef[] templateElementsAndParams = new XSLTElementDef[24];
  312. XSLTElementDef[] templateElementsAndSort = new XSLTElementDef[24];
  313. //exslt
  314. XSLTElementDef[] exsltFunctionElements = new XSLTElementDef[24];
  315. XSLTElementDef[] charTemplateElements = new XSLTElementDef[15];
  316. XSLTElementDef resultElement = new XSLTElementDef(this, null, "*",
  317. null /*alias */,
  318. templateElements /* elements */,
  319. new XSLTAttributeDef[]{
  320. spaceAttrLiteral, // special
  321. xslExcludeResultPrefixesAttr,
  322. xslExtensionElementPrefixesAttr,
  323. xslUseAttributeSetsAttr,
  324. xslVersionAttr,
  325. xslResultAttr,
  326. resultAttr },
  327. new ProcessorLRE(),
  328. ElemLiteralResult.class /* class object */, 20, true);
  329. XSLTElementDef unknownElement =
  330. new XSLTElementDef(this, "*", "unknown", null /*alias */,
  331. templateElementsAndParams /* elements */,
  332. new XSLTAttributeDef[]{ xslExcludeResultPrefixesAttr,
  333. xslExtensionElementPrefixesAttr,
  334. xslUseAttributeSetsAttr,
  335. xslVersionAttr,
  336. xslResultAttr,
  337. resultAttr },
  338. new ProcessorUnknown(),
  339. ElemUnknown.class /* class object */, 20, true);
  340. XSLTElementDef xslValueOf = new XSLTElementDef(this,
  341. Constants.S_XSLNAMESPACEURL, "value-of",
  342. null /*alias */, null /* elements */,
  343. new XSLTAttributeDef[]{ selectAttrRequired,
  344. disableOutputEscapingAttr },
  345. new ProcessorTemplateElem(),
  346. ElemValueOf.class /* class object */, 20, true);
  347. XSLTElementDef xslCopyOf = new XSLTElementDef(this,
  348. Constants.S_XSLNAMESPACEURL, "copy-of",
  349. null /*alias */, null /* elements */,
  350. new XSLTAttributeDef[]{ selectAttrRequired },
  351. new ProcessorTemplateElem(),
  352. ElemCopyOf.class /* class object */, 20, true);
  353. XSLTElementDef xslNumber = new XSLTElementDef(this,
  354. Constants.S_XSLNAMESPACEURL, "number",
  355. null /*alias */, null /* elements */,
  356. new XSLTAttributeDef[]{ levelAttr,
  357. countAttr,
  358. fromAttr,
  359. valueAttr,
  360. formatAttr,
  361. langAttr,
  362. letterValueAttr,
  363. groupingSeparatorAVT,
  364. groupingSizeAttr },
  365. new ProcessorTemplateElem(),
  366. ElemNumber.class /* class object */, 20, true);
  367. // <!-- xsl:sort cannot occur after any other elements or
  368. // any non-whitespace character -->
  369. XSLTElementDef xslSort = new XSLTElementDef(this,
  370. Constants.S_XSLNAMESPACEURL,
  371. "sort", null /*alias */,
  372. null /* elements */,
  373. new XSLTAttributeDef[]{
  374. selectAttrDefDot,
  375. langAttr,
  376. dataTypeAttr,
  377. orderAttr,
  378. caseOrderAttr },
  379. new ProcessorTemplateElem(),
  380. ElemSort.class/* class object */, 19, true );
  381. XSLTElementDef xslWithParam = new XSLTElementDef(this,
  382. Constants.S_XSLNAMESPACEURL,
  383. "with-param", null /*alias */,
  384. templateElements /* elements */, // %template;>
  385. new XSLTAttributeDef[]{ nameAttrRequired,
  386. selectAttrOpt }, new ProcessorTemplateElem(),
  387. ElemWithParam.class /* class object */, 19, true);
  388. XSLTElementDef xslApplyTemplates = new XSLTElementDef(this,
  389. Constants.S_XSLNAMESPACEURL,
  390. "apply-templates", null /*alias */,
  391. new XSLTElementDef[]{ xslSort,
  392. xslWithParam } /* elements */, new XSLTAttributeDef[]{
  393. selectAttrDefNode,
  394. modeAttr },
  395. new ProcessorTemplateElem(),
  396. ElemApplyTemplates.class /* class object */, 20, true);
  397. XSLTElementDef xslApplyImports =
  398. new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "apply-imports",
  399. null /*alias */, null /* elements */,
  400. new XSLTAttributeDef[]{},
  401. new ProcessorTemplateElem(),
  402. ElemApplyImport.class /* class object */);
  403. XSLTElementDef xslForEach = new XSLTElementDef(this,
  404. Constants.S_XSLNAMESPACEURL, "for-each",
  405. null /*alias */, templateElementsAndSort, // (#PCDATA %instructions; %result-elements; | xsl:sort)*
  406. new XSLTAttributeDef[]{ selectAttrRequired,
  407. spaceAttr },
  408. new ProcessorTemplateElem(),
  409. ElemForEach.class /* class object */, true, false, true, 20, true);
  410. XSLTElementDef xslIf = new XSLTElementDef(this,
  411. Constants.S_XSLNAMESPACEURL,
  412. "if", null /*alias */,
  413. templateElements /* elements */, // %template;
  414. new XSLTAttributeDef[]{
  415. testAttrRequired,
  416. spaceAttr }, new ProcessorTemplateElem(),
  417. ElemIf.class /* class object */, 20, true);
  418. XSLTElementDef xslWhen =
  419. new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "when",
  420. null /*alias */, templateElements /* elements */, // %template;>
  421. new XSLTAttributeDef[]{
  422. testAttrRequired,
  423. spaceAttr }, new ProcessorTemplateElem(),
  424. ElemWhen.class /* class object */,
  425. false, true, 1, true);
  426. XSLTElementDef xslOtherwise = new XSLTElementDef(this,
  427. Constants.S_XSLNAMESPACEURL, "otherwise",
  428. null /*alias */,
  429. templateElements /* elements */, // %template;>
  430. new XSLTAttributeDef[]{ spaceAttr },
  431. new ProcessorTemplateElem(),
  432. ElemOtherwise.class /* class object */,
  433. false, false, 2, false);
  434. XSLTElementDef xslChoose = new XSLTElementDef(this,
  435. Constants.S_XSLNAMESPACEURL, "choose",
  436. null /*alias */,
  437. new XSLTElementDef[]{ xslWhen,
  438. xslOtherwise } /* elements */,
  439. new XSLTAttributeDef[]{ spaceAttr },
  440. new ProcessorTemplateElem(),
  441. ElemChoose.class /* class object */, true, false, true, 20, true);
  442. XSLTElementDef xslAttribute = new XSLTElementDef(this,
  443. Constants.S_XSLNAMESPACEURL, "attribute",
  444. null /*alias */,
  445. charTemplateElements /* elements */, // %char-template;>
  446. new XSLTAttributeDef[]{ nameAVTRequired,
  447. namespaceAVTOpt,
  448. spaceAttr },
  449. new ProcessorTemplateElem(),
  450. ElemAttribute.class /* class object */, 20, true);
  451. XSLTElementDef xslCallTemplate =
  452. new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "call-template",
  453. null /*alias */,
  454. new XSLTElementDef[]{ xslWithParam } /* elements */,
  455. new XSLTAttributeDef[]{ nameAttrRequired },
  456. new ProcessorTemplateElem(),
  457. ElemCallTemplate.class /* class object */, 20, true);
  458. XSLTElementDef xslVariable = new XSLTElementDef(this,
  459. Constants.S_XSLNAMESPACEURL, "variable",
  460. null /*alias */,
  461. templateElements /* elements */, // %template;>
  462. new XSLTAttributeDef[]{ nameAttrRequired,
  463. selectAttrOpt },
  464. new ProcessorTemplateElem(),
  465. ElemVariable.class /* class object */, 20, true);
  466. XSLTElementDef xslParam = new XSLTElementDef(this,
  467. Constants.S_XSLNAMESPACEURL, "param",
  468. null /*alias */,
  469. templateElements /* elements */, // %template;>
  470. new XSLTAttributeDef[]{ nameAttrRequired,
  471. selectAttrOpt },
  472. new ProcessorTemplateElem(),
  473. ElemParam.class /* class object */, 19, true);
  474. XSLTElementDef xslText =
  475. new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "text",
  476. null /*alias */,
  477. new XSLTElementDef[]{ charData } /* elements */,
  478. new XSLTAttributeDef[]{ disableOutputEscapingAttr },
  479. new ProcessorText(),
  480. ElemText.class /* class object */, 20, true);
  481. XSLTElementDef xslProcessingInstruction =
  482. new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL,
  483. "processing-instruction", null /*alias */,
  484. charTemplateElements /* elements */, // %char-template;>
  485. new XSLTAttributeDef[]{
  486. nameAVT_NCNAMERequired,
  487. spaceAttr },
  488. new ProcessorTemplateElem(),
  489. ElemPI.class /* class object */, 20, true);
  490. XSLTElementDef xslElement = new XSLTElementDef(this,
  491. Constants.S_XSLNAMESPACEURL, "element",
  492. null /*alias */,
  493. templateElements /* elements */, // %template;
  494. new XSLTAttributeDef[]{ nameAVTRequired,
  495. namespaceAVTOpt,
  496. useAttributeSetsAttr,
  497. spaceAttr },
  498. new ProcessorTemplateElem(),
  499. ElemElement.class /* class object */, 20, true);
  500. XSLTElementDef xslComment = new XSLTElementDef(this,
  501. Constants.S_XSLNAMESPACEURL, "comment",
  502. null /*alias */,
  503. charTemplateElements /* elements */, // %char-template;>
  504. new XSLTAttributeDef[]{ spaceAttr },
  505. new ProcessorTemplateElem(),
  506. ElemComment.class /* class object */, 20, true);
  507. XSLTElementDef xslCopy =
  508. new XSLTElementDef(this, Constants.S_XSLNAMESPACEURL, "copy",
  509. null /*alias */, templateElements /* elements */, // %template;>
  510. new XSLTAttributeDef[]{
  511. spaceAttr,
  512. useAttributeSetsAttr },
  513. new ProcessorTemplateElem(),
  514. ElemCopy.class /* class object */, 20, true);
  515. XSLTElementDef xslMessage = new XSLTElementDef(this,
  516. Constants.S_XSLNAMESPACEURL, "message",
  517. null /*alias */,
  518. templateElements /* elements */, // %template;>
  519. new XSLTAttributeDef[]{ terminateAttr },
  520. new ProcessorTemplateElem(),
  521. ElemMessage.class /* class object */, 20, true);
  522. XSLTElementDef xslFallback = new XSLTElementDef(this,
  523. Constants.S_XSLNAMESPACEURL, "fallback",
  524. null /*alias */,
  525. templateElements /* elements */, // %template;>
  526. new XSLTAttributeDef[]{ spaceAttr },
  527. new ProcessorTemplateElem(),
  528. ElemFallback.class /* class object */, 20, true);
  529. //exslt
  530. XSLTElementDef exsltFunction =
  531. new XSLTElementDef(this,
  532. Constants.S_EXSLT_FUNCTIONS_URL,
  533. "function",
  534. null /*alias */,
  535. exsltFunctionElements /* elements */,
  536. new XSLTAttributeDef[]{ nameAttrRequired },
  537. new ProcessorExsltFunction(),
  538. ElemExsltFunction.class /* class object */);
  539. XSLTElementDef exsltResult =
  540. new XSLTElementDef(this,
  541. Constants.S_EXSLT_FUNCTIONS_URL,
  542. "result",
  543. null /*alias */,
  544. templateElements /* elements */,
  545. new XSLTAttributeDef[]{ selectAttrOpt },
  546. new ProcessorExsltFuncResult(),
  547. ElemExsltFuncResult.class /* class object */);
  548. int i = 0;
  549. templateElements[i++] = charData; // #PCDATA
  550. // char-instructions
  551. templateElements[i++] = xslApplyTemplates;
  552. templateElements[i++] = xslCallTemplate;
  553. templateElements[i++] = xslApplyImports;
  554. templateElements[i++] = xslForEach;
  555. templateElements[i++] = xslValueOf;
  556. templateElements[i++] = xslCopyOf;
  557. templateElements[i++] = xslNumber;
  558. templateElements[i++] = xslChoose;
  559. templateElements[i++] = xslIf;
  560. templateElements[i++] = xslText;
  561. templateElements[i++] = xslCopy;
  562. templateElements[i++] = xslVariable;
  563. templateElements[i++] = xslMessage;
  564. templateElements[i++] = xslFallback;
  565. // instructions
  566. templateElements[i++] = xslProcessingInstruction;
  567. templateElements[i++] = xslComment;
  568. templateElements[i++] = xslElement;
  569. templateElements[i++] = xslAttribute;
  570. templateElements[i++] = resultElement;
  571. templateElements[i++] = unknownElement;
  572. templateElements[i++] = exsltFunction;
  573. templateElements[i++] = exsltResult;
  574. int k;
  575. for (k = 0; k < i; k++)
  576. {
  577. templateElementsAndParams[k] = templateElements[k];
  578. templateElementsAndSort[k] = templateElements[k];
  579. exsltFunctionElements[k] = templateElements[k];
  580. }
  581. templateElementsAndParams[k] = xslParam;
  582. templateElementsAndSort[k] = xslSort;
  583. exsltFunctionElements[k] = xslParam;
  584. i = 0;
  585. charTemplateElements[i++] = charData; // #PCDATA
  586. // char-instructions
  587. charTemplateElements[i++] = xslApplyTemplates;
  588. charTemplateElements[i++] = xslCallTemplate;
  589. charTemplateElements[i++] = xslApplyImports;
  590. charTemplateElements[i++] = xslForEach;
  591. charTemplateElements[i++] = xslValueOf;
  592. charTemplateElements[i++] = xslCopyOf;
  593. charTemplateElements[i++] = xslNumber;
  594. charTemplateElements[i++] = xslChoose;
  595. charTemplateElements[i++] = xslIf;
  596. charTemplateElements[i++] = xslText;
  597. charTemplateElements[i++] = xslCopy;
  598. charTemplateElements[i++] = xslVariable;
  599. charTemplateElements[i++] = xslMessage;
  600. charTemplateElements[i++] = xslFallback;
  601. XSLTElementDef importDef = new XSLTElementDef(this,
  602. Constants.S_XSLNAMESPACEURL, "import",
  603. null /*alias */, null /* elements */,
  604. new XSLTAttributeDef[]{ hrefAttr }, // EMPTY
  605. new ProcessorImport(),
  606. null /* class object */,
  607. 1, true);
  608. XSLTElementDef includeDef = new XSLTElementDef(this,
  609. Constants.S_XSLNAMESPACEURL, "include",
  610. null /*alias */, null /* elements */, // EMPTY
  611. new XSLTAttributeDef[]{ hrefAttr },
  612. new ProcessorInclude(),
  613. null /* class object */,
  614. 20, true);
  615. XSLTAttributeDef[] scriptAttrs = new XSLTAttributeDef[]{
  616. new XSLTAttributeDef(null, "lang", XSLTAttributeDef.T_NMTOKEN,
  617. true, false,XSLTAttributeDef.WARNING),
  618. new XSLTAttributeDef(null, "src", XSLTAttributeDef.T_URL,
  619. false, false,XSLTAttributeDef.WARNING)};
  620. XSLTAttributeDef[] componentAttrs = new XSLTAttributeDef[]{
  621. new XSLTAttributeDef(null, "prefix", XSLTAttributeDef.T_NMTOKEN,
  622. true, false,XSLTAttributeDef.WARNING),
  623. new XSLTAttributeDef(null, "elements", XSLTAttributeDef.T_STRINGLIST,
  624. false, false,XSLTAttributeDef.WARNING),
  625. new XSLTAttributeDef(null, "functions", XSLTAttributeDef.T_STRINGLIST,
  626. false, false,XSLTAttributeDef.WARNING) };
  627. XSLTElementDef[] topLevelElements = new XSLTElementDef[]
  628. {includeDef,
  629. importDef,
  630. // resultElement,
  631. whiteSpaceOnly,
  632. unknownElement,
  633. new XSLTElementDef(
  634. this,
  635. Constants.S_XSLNAMESPACEURL,
  636. "strip-space",
  637. null /*alias */,
  638. null /* elements */,
  639. new XSLTAttributeDef[]{
  640. elementsAttr },
  641. new ProcessorStripSpace(),
  642. null /* class object */, 20, true),
  643. new XSLTElementDef(
  644. this,
  645. Constants.S_XSLNAMESPACEURL,
  646. "preserve-space",
  647. null /*alias */,
  648. null /* elements */,
  649. new XSLTAttributeDef[]{
  650. elementsAttr },
  651. new ProcessorPreserveSpace(),
  652. null /* class object */, 20, true),
  653. new XSLTElementDef(
  654. this,
  655. Constants.S_XSLNAMESPACEURL,
  656. "output",
  657. null /*alias */,
  658. null /* elements */,
  659. new XSLTAttributeDef[]{
  660. methodAttr,
  661. versionAttr,
  662. encodingAttr,
  663. omitXmlDeclarationAttr,
  664. standaloneAttr,
  665. doctypePublicAttr,
  666. doctypeSystemAttr,
  667. cdataSectionElementsAttr,
  668. indentAttr,
  669. mediaTypeAttr,
  670. XSLTAttributeDef.m_foreignAttr },
  671. new ProcessorOutputElem(), null /* class object */, 20, true),
  672. new XSLTElementDef(
  673. this,
  674. Constants.S_XSLNAMESPACEURL,
  675. "key",
  676. null /*alias */,
  677. null /* elements */, // EMPTY
  678. new XSLTAttributeDef[]{ nameAttrRequired,
  679. matchAttrRequired,
  680. useAttr },
  681. new ProcessorKey(), null /* class object */, 20, true),
  682. new XSLTElementDef(
  683. this,
  684. Constants.S_XSLNAMESPACEURL,
  685. "decimal-format",
  686. null /*alias */,
  687. null /* elements */, // EMPTY
  688. new XSLTAttributeDef[]{
  689. nameAttrOpt_ERROR,
  690. decimalSeparatorAttr,
  691. groupingSeparatorAttr,
  692. infinityAttr,
  693. minusSignAttr,
  694. NaNAttr,
  695. percentAttr,
  696. perMilleAttr,
  697. zeroDigitAttr,
  698. digitAttr,
  699. patternSeparatorAttr },
  700. new ProcessorDecimalFormat(),
  701. null /* class object */, 20, true),
  702. new XSLTElementDef(
  703. this,
  704. Constants.S_XSLNAMESPACEURL,
  705. "attribute-set",
  706. null /*alias */,
  707. new XSLTElementDef[]{
  708. xslAttribute } /* elements */,
  709. new XSLTAttributeDef[]{
  710. nameAttrRequired,
  711. useAttributeSetsAttr },
  712. new ProcessorAttributeSet(),
  713. null /* class object */, 20, true),
  714. new XSLTElementDef(
  715. this,
  716. Constants.S_XSLNAMESPACEURL,
  717. "variable",
  718. null /*alias */,
  719. templateElements /* elements */,
  720. new XSLTAttributeDef[]{
  721. nameAttrRequired,
  722. selectAttrOpt },
  723. new ProcessorGlobalVariableDecl(),
  724. ElemVariable.class /* class object */, 20, true),
  725. new XSLTElementDef(
  726. this,
  727. Constants.S_XSLNAMESPACEURL,
  728. "param",
  729. null /*alias */,
  730. templateElements /* elements */,
  731. new XSLTAttributeDef[]{
  732. nameAttrRequired,
  733. selectAttrOpt },
  734. new ProcessorGlobalParamDecl(),
  735. ElemParam.class /* class object */, 20, true),
  736. new XSLTElementDef(
  737. this,
  738. Constants.S_XSLNAMESPACEURL,
  739. "template",
  740. null /*alias */,
  741. templateElementsAndParams /* elements */,
  742. new XSLTAttributeDef[]{
  743. matchAttrOpt,
  744. nameAttrOpt_ERROR,
  745. priorityAttr,
  746. modeAttr,
  747. spaceAttr },
  748. new ProcessorTemplate(), ElemTemplate.class /* class object */, true, 20, true),
  749. new XSLTElementDef(
  750. this,
  751. Constants.S_XSLNAMESPACEURL,
  752. "namespace-alias",
  753. null /*alias */,
  754. null /* elements */, // EMPTY
  755. new XSLTAttributeDef[]{
  756. stylesheetPrefixAttr,
  757. resultPrefixAttr },
  758. new ProcessorNamespaceAlias(), null /* class object */, 20, true),
  759. new XSLTElementDef(
  760. this,
  761. Constants.S_BUILTIN_EXTENSIONS_URL,
  762. "component",
  763. null /*alias */,
  764. new XSLTElementDef[]{
  765. new XSLTElementDef(
  766. this,
  767. Constants.S_BUILTIN_EXTENSIONS_URL,
  768. "script",
  769. null /*alias */,
  770. new XSLTElementDef[]{
  771. charData } /* elements */,
  772. scriptAttrs,
  773. new ProcessorLRE(),
  774. ElemExtensionScript.class /* class object */, 20, true) }, // EMPTY
  775. componentAttrs,
  776. new ProcessorLRE(), ElemExtensionDecl.class /* class object */),
  777. new XSLTElementDef(
  778. this,
  779. Constants.S_BUILTIN_OLD_EXTENSIONS_URL,
  780. "component",
  781. null /*alias */,
  782. new XSLTElementDef[]{
  783. new XSLTElementDef(
  784. this,
  785. Constants.S_BUILTIN_OLD_EXTENSIONS_URL,
  786. "script",
  787. null /*alias */,
  788. new XSLTElementDef[]{
  789. charData } /* elements */,
  790. scriptAttrs,
  791. new ProcessorLRE(),
  792. ElemExtensionScript.class /* class object */, 20, true) }, // EMPTY
  793. componentAttrs,
  794. new ProcessorLRE(), ElemExtensionDecl.class /* class object */),
  795. exsltFunction}/* exslt */; //end of topevelElements
  796. XSLTAttributeDef excludeResultPrefixesAttr =
  797. new XSLTAttributeDef(null, "exclude-result-prefixes",
  798. XSLTAttributeDef.T_STRINGLIST, false,false,XSLTAttributeDef.WARNING);
  799. XSLTAttributeDef extensionElementPrefixesAttr =
  800. new XSLTAttributeDef(null, "extension-element-prefixes",
  801. XSLTAttributeDef.T_PREFIX_URLLIST, false,false,XSLTAttributeDef.WARNING);
  802. XSLTAttributeDef idAttr = new XSLTAttributeDef(null, "id",
  803. XSLTAttributeDef.T_CDATA, false,false,XSLTAttributeDef.WARNING);
  804. XSLTAttributeDef versionAttrRequired = new XSLTAttributeDef(null,
  805. "version",
  806. XSLTAttributeDef.T_NMTOKEN,
  807. true,false,XSLTAttributeDef.WARNING);
  808. XSLTElementDef stylesheetElemDef = new XSLTElementDef(this,
  809. Constants.S_XSLNAMESPACEURL,
  810. "stylesheet", "transform",
  811. topLevelElements,
  812. new XSLTAttributeDef[]{
  813. extensionElementPrefixesAttr,
  814. excludeResultPrefixesAttr,
  815. idAttr,
  816. versionAttrRequired,
  817. spaceAttr }, new ProcessorStylesheetElement(), /* ContentHandler */
  818. null /* class object */,
  819. true, -1, false);
  820. importDef.setElements(new XSLTElementDef[]{ stylesheetElemDef,
  821. resultElement,
  822. unknownElement });
  823. includeDef.setElements(new XSLTElementDef[]{ stylesheetElemDef,
  824. resultElement,
  825. unknownElement });
  826. build(null, null, null, new XSLTElementDef[]{ stylesheetElemDef,
  827. whiteSpaceOnly,
  828. resultElement,
  829. unknownElement }, null,
  830. new ProcessorStylesheetDoc(), /* ContentHandler */
  831. null /* class object */
  832. );
  833. }
  834. /**
  835. * A hashtable of all available built-in elements for use by the element-available
  836. * function.
  837. * TODO: When we convert to Java2, this should be a Set.
  838. */
  839. private Hashtable m_availElems = new Hashtable();
  840. /**
  841. * Get the table of available elements.
  842. *
  843. * @return table of available elements, keyed by qualified names, and with
  844. * values of the same qualified names.
  845. */
  846. public Hashtable getElemsAvailable()
  847. {
  848. return m_availElems;
  849. }
  850. /**
  851. * Adds a new element name to the Hashtable of available elements.
  852. * @param elemName The name of the element to add to the Hashtable of available elements.
  853. */
  854. void addAvailableElement(QName elemName)
  855. {
  856. m_availElems.put(elemName, elemName);
  857. }
  858. /**
  859. * Determines whether the passed element name is present in the list of available elements.
  860. * @param elemName The name of the element to look up.
  861. *
  862. * @return true if an element corresponding to elemName is available.
  863. */
  864. public boolean elementAvailable(QName elemName)
  865. {
  866. return m_availElems.containsKey(elemName);
  867. }
  868. }