KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.style;
2 import com.icl.saxon.tree.AttributeCollection;
3 import com.icl.saxon.*;
4
5 import com.icl.saxon.om.NamePool;
6 import com.icl.saxon.om.Name;
7 import com.icl.saxon.om.NamespaceException;
8 import com.icl.saxon.expr.*;
9 import com.icl.saxon.output.*;
10 import org.xml.sax.*;
11 import java.io.*;
12 import java.util.*;
13 import java.text.*;
14 import javax.xml.transform.*;
15
16 /**
17 * An xsl:output element in the stylesheet.
18 */

19
20 public class XSLOutput extends XSLGeneralOutput {
21
22     public void prepareAttributes() throws TransformerConfigurationException {
23         super.prepareAttributes();
24         if (href!=null) {
25             compileError("The href attribute is not allowed on this element");
26         }
27     }
28
29     public void validate() throws TransformerConfigurationException {
30         checkTopLevel();
31         checkEmpty();
32         
33         // AVTs are not allowed with version="1.0"
34

35         if (!forwardsCompatibleModeIsEnabled()) {
36             AttributeCollection atts = getAttributeList();
37             for (int a=0; a<atts.getLength(); a++) {
38                 if (atts.getValue(a).indexOf('{') >= 0) {
39                     compileError("To use attribute value templates in xsl:output, set xsl:stylesheet version='1.1'");
40                     break;
41                 }
42             }
43         }
44     }
45     
46     public void process(Context context) throws TransformerException {}
47
48     /**
49     * Gather the unvalidated and unexpanded values of the properties.
50     */

51     
52     protected Properties gatherOutputProperties(Properties details) {
53         StandardNames sn = getStandardNames();
54         AttributeCollection atts = getAttributeList();
55         if (method != null) {
56             details.put(OutputKeys.METHOD,
57                                 atts.getValueByFingerprint(sn.METHOD));
58         }
59
60         if (version != null) {
61             details.put(OutputKeys.VERSION,
62                                 atts.getValueByFingerprint(sn.VERSION));
63         }
64
65         if (indent != null) {
66             details.put(OutputKeys.INDENT,
67                                 atts.getValueByFingerprint(sn.INDENT));
68         }
69         
70         if (indentSpaces != null) {
71             details.put(SaxonOutputKeys.INDENT_SPACES,
72                                 atts.getValueByFingerprint(sn.SAXON_INDENT_SPACES));
73         }
74
75         if (encoding != null) {
76             details.put(OutputKeys.ENCODING,
77                                 atts.getValueByFingerprint(sn.ENCODING));
78         }
79
80         if (mediaType != null) {
81             details.put(OutputKeys.MEDIA_TYPE,
82                                 atts.getValueByFingerprint(sn.MEDIA_TYPE));
83         }
84
85         if (doctypeSystem != null) {
86             details.put(OutputKeys.DOCTYPE_SYSTEM,
87                                 atts.getValueByFingerprint(sn.DOCTYPE_SYSTEM));
88         }
89         
90         if (doctypePublic != null) {
91             details.put(OutputKeys.DOCTYPE_PUBLIC,
92                                 atts.getValueByFingerprint(sn.DOCTYPE_PUBLIC));
93         }
94
95         if (omitDeclaration != null) {
96             details.put(OutputKeys.OMIT_XML_DECLARATION,
97                                 atts.getValueByFingerprint(sn.OMIT_XML_DECLARATION));
98         }
99
100         if (standalone != null) {
101             details.put(OutputKeys.STANDALONE,
102                                 atts.getValueByFingerprint(sn.STANDALONE));
103         }
104
105         if (cdataElements != null) {
106             String JavaDoc existing = details.getProperty(OutputKeys.CDATA_SECTION_ELEMENTS);
107             String JavaDoc s = existing + " " + atts.getValueByFingerprint(sn.CDATA_SECTION_ELEMENTS);
108             details.put(OutputKeys.CDATA_SECTION_ELEMENTS, s);
109         }
110
111         if (nextInChain != null) { //TODO
112

113         }
114         
115         return details;
116     }
117 }
118
119 //
120
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
121
// you may not use this file except in compliance with the License. You may obtain a copy of the
122
// License at http://www.mozilla.org/MPL/
123
//
124
// Software distributed under the License is distributed on an "AS IS" basis,
125
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
126
// See the License for the specific language governing rights and limitations under the License.
127
//
128
// The Original Code is: all this file.
129
//
130
// The Initial Developer of the Original Code is
131
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
132
//
133
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
134
//
135
// Contributor(s): none.
136
//
137
Popular Tags