KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xalan > processor > ProcessorNamespaceAlias


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17  * $Id: ProcessorNamespaceAlias.java,v 1.11 2004/02/11 18:15:50 minchau Exp $
18  */

19 package org.apache.xalan.processor;
20
21 import org.apache.xalan.templates.NamespaceAlias;
22 import org.xml.sax.Attributes JavaDoc;
23
24 /**
25  * TransformerFactory for xsl:namespace-alias markup.
26  * A stylesheet can use the xsl:namespace-alias element to
27  * declare that one namespace URI is an alias for another namespace URI.
28  * <pre>
29  * <!ELEMENT xsl:namespace-alias EMPTY>
30  * <!ATTLIST xsl:namespace-alias
31  * stylesheet-prefix CDATA #REQUIRED
32  * result-prefix CDATA #REQUIRED
33  * >
34  * </pre>
35  * @see <a HREF="http://www.w3.org/TR/xslt#dtd">XSLT DTD</a>
36  * @see <a HREF="http://www.w3.org/TR/xslt#literal-result-element">literal-result-element in XSLT Specification</a>
37  */

38 class ProcessorNamespaceAlias extends XSLTElementProcessor
39 {
40
41   /**
42    * Receive notification of the start of an xsl:namespace-alias element.
43    *
44    * @param handler The calling StylesheetHandler/TemplatesBuilder.
45    * @param uri The Namespace URI, or the empty string if the
46    * element has no Namespace URI or if Namespace
47    * processing is not being performed.
48    * @param localName The local name (without prefix), or the
49    * empty string if Namespace processing is not being
50    * performed.
51    * @param rawName The raw XML 1.0 name (with prefix), or the
52    * empty string if raw names are not available.
53    * @param attributes The attributes attached to the element. If
54    * there are no attributes, it shall be an empty
55    * Attributes object.
56    */

57   public void startElement(
58           StylesheetHandler handler, String JavaDoc uri, String JavaDoc localName, String JavaDoc rawName, Attributes JavaDoc attributes)
59             throws org.xml.sax.SAXException JavaDoc
60   {
61
62     NamespaceAlias na = new NamespaceAlias(handler.nextUid());
63
64     setPropertiesFromAttributes(handler, rawName, attributes, na);
65     String JavaDoc prefix = na.getStylesheetPrefix();
66     if(prefix.equals("#default"))
67     {
68       prefix = "";
69       na.setStylesheetPrefix(prefix);
70     }
71     String JavaDoc stylesheetNS = handler.getNamespaceForPrefix(prefix);
72     na.setStylesheetNamespace(stylesheetNS);
73     prefix = na.getResultPrefix();
74     if(prefix.equals("#default"))
75     {
76       prefix = "";
77       na.setResultPrefix(prefix);
78     }
79     String JavaDoc resultNS = handler.getNamespaceForPrefix(prefix);
80     na.setResultNamespace(resultNS);
81     handler.getStylesheet().setNamespaceAlias(na);
82     handler.getStylesheet().appendChild(na);
83   }
84 }
85
Popular Tags