2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 * $Id: ElemText.java 468643 2006-10-28 06:56:03Z minchau $
21 package org.apache.xalan.templates;
23 import org.apache.xalan.res.XSLTErrorResources;
26 * Implement xsl:template.
27 * This primarily acts as a marker on the element
28 * stack to signal that whitespace should be preserved.
30 * <!ELEMENT xsl:text (#PCDATA)>
32 * disable-output-escaping (yes|no) "no"
35 * @see <a href="http://www.w3.org/TR/xslt#section-Creating-Text">section-Creating-Text in XSLT Specification</a>
38 public class ElemText extends ElemTemplateElement
40 static final long serialVersionUID = 1383140876182316711L;
43 * Tells if this element should disable escaping.
46 private boolean m_disableOutputEscaping = false;
49 * Set the "disable-output-escaping" attribute.
50 * Normally, the xml output method escapes & and < (and
51 * possibly other characters) when outputting text nodes.
52 * This ensures that the output is well-formed XML. However,
53 * it is sometimes convenient to be able to produce output
54 * that is almost, but not quite well-formed XML; for
55 * example, the output may include ill-formed sections
56 * which are intended to be transformed into well-formed
57 * XML by a subsequent non-XML aware process. For this reason,
58 * XSLT provides a mechanism for disabling output escaping.
59 * An xsl:value-of or xsl:text element may have a
60 * disable-output-escaping attribute; the allowed values
61 * are yes or no; the default is no; if the value is yes,
62 * then a text node generated by instantiating the xsl:value-of
63 * or xsl:text element should be output without any escaping.
64 * @see <a href="http://www.w3.org/TR/xslt#disable-output-escaping">disable-output-escaping in XSLT Specification</a>
66 * @param v Boolean flag indicating whether this element should disable escaping
68 public void setDisableOutputEscaping(boolean v)
70 m_disableOutputEscaping = v;
74 * Get the "disable-output-escaping" attribute.
75 * Normally, the xml output method escapes & and < (and
76 * possibly other characters) when outputting text nodes.
77 * This ensures that the output is well-formed XML. However,
78 * it is sometimes convenient to be able to produce output
79 * that is almost, but not quite well-formed XML; for
80 * example, the output may include ill-formed sections
81 * which are intended to be transformed into well-formed
82 * XML by a subsequent non-XML aware process. For this reason,
83 * XSLT provides a mechanism for disabling output escaping.
84 * An xsl:value-of or xsl:text element may have a
85 * disable-output-escaping attribute; the allowed values
86 * are yes or no; the default is no; if the value is yes,
87 * then a text node generated by instantiating the xsl:value-of
88 * or xsl:text element should be output without any escaping.
89 * @see <a href="http://www.w3.org/TR/xslt#disable-output-escaping">disable-output-escaping in XSLT Specification</a>
91 * @return Boolean flag indicating whether this element should disable escaping
93 public boolean getDisableOutputEscaping()
95 return m_disableOutputEscaping;
99 * Get an integer representation of the element type.
101 * @return An integer representation of the element, defined in the
103 * @see org.apache.xalan.templates.Constants
105 public int getXSLToken()
107 return Constants.ELEMNAME_TEXT;
111 * Return the node name.
113 * @return The element's name
115 public String getNodeName()
117 return Constants.ELEMNAME_TEXT_STRING;
121 * Add a child to the child list.
123 * @param newChild Child to add to children list
125 * @return Child added to children list
127 * @throws DOMException
129 public ElemTemplateElement appendChild(ElemTemplateElement newChild)
132 int type = ((ElemTemplateElement) newChild).getXSLToken();
136 case Constants.ELEMNAME_TEXTLITERALRESULT :
139 error(XSLTErrorResources.ER_CANNOT_ADD,
140 new Object[]{ newChild.getNodeName(),
141 this.getNodeName() }); //"Can not add " +((ElemTemplateElement)newChild).m_elemName +
143 //" to " + this.m_elemName);
146 return super.appendChild(newChild);