KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > style > XSLNamespaceAlias


1 package net.sf.saxon.style;
2 import net.sf.saxon.expr.Expression;
3 import net.sf.saxon.instruct.Executable;
4 import net.sf.saxon.om.AttributeCollection;
5 import net.sf.saxon.om.NamePool;
6 import net.sf.saxon.om.NamespaceException;
7 import net.sf.saxon.trans.XPathException;
8
9
10 /**
11 * An xsl:namespace-alias element in the stylesheet. <br>
12 */

13
14 public class XSLNamespaceAlias extends StyleElement {
15
16     private short stylesheetURICode;
17     private int resultNamespaceCode;
18
19     public void prepareAttributes() throws XPathException {
20
21         String JavaDoc stylesheetPrefix=null;
22         String JavaDoc resultPrefix=null;
23
24         AttributeCollection atts = getAttributeList();
25
26         for (int a=0; a<atts.getLength(); a++) {
27             int nc = atts.getNameCode(a);
28             String JavaDoc f = getNamePool().getClarkName(nc);
29             if (f==StandardNames.STYLESHEET_PREFIX) {
30                 stylesheetPrefix = atts.getValue(a).trim();
31             } else if (f==StandardNames.RESULT_PREFIX) {
32                 resultPrefix = atts.getValue(a).trim();
33             } else {
34                 checkUnknownAttribute(nc);
35             }
36         }
37         if (stylesheetPrefix==null) {
38             reportAbsence("stylesheet-prefix");
39             return;
40         }
41         if (stylesheetPrefix.equals("#default")) {
42             stylesheetPrefix="";
43         }
44         if (resultPrefix==null) {
45             reportAbsence("result-prefix");
46             return;
47         }
48         if (resultPrefix.equals("#default")) {
49             resultPrefix="";
50         }
51         try {
52             String JavaDoc ssURI = getURIForPrefix(stylesheetPrefix, true);
53             if (ssURI == null) {
54                 compileError("stylesheet-prefix " + stylesheetPrefix + " has not been declared", "XTSE0812");
55                     // TODO: error code provisional. See W3C Bugzilla 1879
56
// recovery action
57
stylesheetURICode = 0;
58                 resultNamespaceCode = 0;
59                 return;
60             }
61             stylesheetURICode = getURICodeForPrefix(stylesheetPrefix);
62             NamePool pool = getNamePool();
63             String JavaDoc resultURI = getURIForPrefix(resultPrefix, true);
64             if (resultURI == null) {
65                 compileError("result-prefix " + resultPrefix + " has not been declared", "XTSE0812");
66                     // TODO: error code provisional. See W3C Bugzilla 1879
67
// recovery action
68
stylesheetURICode = 0;
69                 resultNamespaceCode = 0;
70                 return;
71             }
72             resultNamespaceCode = pool.getNamespaceCode(
73                                             resultPrefix,
74                                             resultURI);
75         } catch (NamespaceException err) {
76             compileError(err.getMessage());
77         }
78     }
79
80     public void validate() throws XPathException {
81         checkTopLevel(null);
82     }
83
84     public Expression compile(Executable exec) throws XPathException {
85         return null;
86     }
87
88     public short getStylesheetURICode() {
89         return stylesheetURICode;
90     }
91
92     public int getResultNamespaceCode() {
93         return resultNamespaceCode;
94     }
95
96 }
97
98 //
99
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
100
// you may not use this file except in compliance with the License. You may obtain a copy of the
101
// License at http://www.mozilla.org/MPL/
102
//
103
// Software distributed under the License is distributed on an "AS IS" basis,
104
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
105
// See the License for the specific language governing rights and limitations under the License.
106
//
107
// The Original Code is: all this file.
108
//
109
// The Initial Developer of the Original Code is Michael H. Kay.
110
//
111
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
112
//
113
// Contributor(s): none.
114
//
115
Popular Tags