01: package net.sf.saxon.style;
02:
03: import net.sf.saxon.expr.Expression;
04: import net.sf.saxon.instruct.Doctype;
05: import net.sf.saxon.instruct.Executable;
06: import net.sf.saxon.om.AttributeCollection;
07: import net.sf.saxon.om.Axis;
08: import net.sf.saxon.trans.XPathException;
09: import net.sf.saxon.value.EmptySequence;
10:
11: /**
12: * A saxon:doctype element in the stylesheet.
13: */
14:
15: public class SaxonDoctype extends StyleElement {
16:
17: /**
18: * Determine whether this node is an instruction.
19: * @return true - it is an instruction
20: */
21:
22: public boolean isInstruction() {
23: return true;
24: }
25:
26: /**
27: * Determine whether this type of element is allowed to contain a template-body
28: * @return true: yes, it may contain a template-body
29: */
30:
31: public boolean mayContainSequenceConstructor() {
32: return true;
33: }
34:
35: public void prepareAttributes() throws XPathException {
36:
37: AttributeCollection atts = getAttributeList();
38: for (int a = 0; a < atts.getLength(); a++) {
39: int nc = atts.getNameCode(a);
40: checkUnknownAttribute(nc);
41: }
42:
43: }
44:
45: public void validate() throws XPathException {
46: checkWithinTemplate();
47: }
48:
49: public Expression compile(Executable exec) throws XPathException {
50: Expression content = compileSequenceConstructor(exec,
51: iterateAxis(Axis.CHILD), true);
52: if (content == null) {
53: content = EmptySequence.getInstance();
54: }
55: Doctype inst = new Doctype(content);
56: return inst;
57: }
58:
59: }
60: //
61: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
62: // you may not use this file except in compliance with the License. You may obtain a copy of the
63: // License at http://www.mozilla.org/MPL/
64: //
65: // Software distributed under the License is distributed on an "AS IS" basis,
66: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
67: // See the License for the specific language governing rights and limitations under the License.
68: //
69: // The Original Code is: all this file.
70: //
71: // The Initial Developer of the Original Code is Michael H. Kay.
72: //
73: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
74: //
75: // Contributor(s): none.
76: //
|