1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.xml;
17
18 import org.apache.commons.jelly.JellyTagException;
19 import org.apache.commons.jelly.MissingAttributeException;
20 import org.apache.commons.jelly.XMLOutput;
21 import org.apache.commons.jelly.xpath.XPathTagSupport;
22
23 import org.xml.sax.SAXException;
24
25 /***
26 * A tag which outputs a DOCTYPE declaration to the current XML output pipe.
27 * Note that there should only be a single DOCTYPE declaration in any XML stream and
28 * it should occur before any element content.
29 *
30 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
31 * @version $Revision: 155420 $
32 */
33 public class DoctypeTag extends XPathTagSupport {
34
35 private String name;
36 private String publicId;
37 private String systemId;
38
39 public DoctypeTag() {
40 }
41
42
43
44 public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
45 if (name == null) {
46 throw new MissingAttributeException( "name" );
47 }
48
49 try {
50 output.startDTD(name, publicId, systemId);
51 invokeBody(output);
52 output.endDTD();
53 } catch (SAXException e) {
54 throw new JellyTagException(e);
55 }
56 }
57
58
59
60 /***
61 * Returns the name.
62 * @return String
63 */
64 public String getName() {
65 return name;
66 }
67
68 /***
69 * Returns the publicId.
70 * @return String
71 */
72 public String getPublicId() {
73 return publicId;
74 }
75
76 /***
77 * Returns the systemId.
78 * @return String
79 */
80 public String getSystemId() {
81 return systemId;
82 }
83
84 /***
85 * Sets the document type name of the DOCTYPE
86 */
87 public void setName(String name) {
88 this.name = name;
89 }
90
91 /***
92 * Sets the declared public identifier for DTD
93 */
94 public void setPublicId(String publicId) {
95 this.publicId = publicId;
96 }
97
98 /***
99 * Sets the declared system identifier for the DTD
100 */
101 public void setSystemId(String systemId) {
102 this.systemId = systemId;
103 }
104
105 }