KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > style > SAXONEntityRef


1 package com.icl.saxon.style;
2 import com.icl.saxon.tree.AttributeCollection;
3 import com.icl.saxon.*;
4
5 import com.icl.saxon.output.*;
6
7 import javax.xml.transform.*;
8
9
10
11 /**
12 * A saxon:entity-ref element in the stylesheet. This causes an entity reference
13 * to be output to the XML or HTML output stream.<BR>
14 */

15
16 public class SAXONEntityRef extends StyleElement {
17
18     String JavaDoc nameAttribute;
19
20     /**
21     * Determine whether this node is an instruction.
22     * @return true - it is an instruction
23     */

24
25     public boolean isInstruction() {
26         return true;
27     }
28
29
30     public void prepareAttributes() throws TransformerConfigurationException {
31
32         StandardNames sn = getStandardNames();
33         AttributeCollection atts = getAttributeList();
34         
35         for (int a=0; a<atts.getLength(); a++) {
36             int nc = atts.getNameCode(a);
37             int f = nc & 0xfffff;
38             if (f==sn.NAME) {
39                 nameAttribute = atts.getValue(a);
40             } else {
41                 checkUnknownAttribute(nc);
42             }
43         }
44         
45         if (nameAttribute==null) {
46             reportAbsence("name");
47         }
48     }
49
50     public void validate() throws TransformerConfigurationException {
51         checkWithinTemplate();
52         checkEmpty();
53     }
54
55     public void process(Context context) throws TransformerException {
56         Outputter out = context.getOutputter();
57         out.setEscaping(false);
58         out.writeContent('&' + nameAttribute + ';');
59         out.setEscaping(true);
60     }
61
62 }
63 //
64
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
65
// you may not use this file except in compliance with the License. You may obtain a copy of the
66
// License at http://www.mozilla.org/MPL/
67
//
68
// Software distributed under the License is distributed on an "AS IS" basis,
69
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
70
// See the License for the specific language governing rights and limitations under the License.
71
//
72
// The Original Code is: all this file.
73
//
74
// The Initial Developer of the Original Code is
75
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
76
//
77
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
78
//
79
// Contributor(s): none.
80
//
81
Popular Tags