Home » xmlbeans-2.5.0-src » org.apache.xmlbeans.impl.xpath » saxon » [javadoc | source]

    1   /*   Copyright 2004 The Apache Software Foundation
    2    *
    3    *   Licensed under the Apache License, Version 2.0 (the "License");
    4    *   you may not use this file except in compliance with the License.
    5    *   You may obtain a copy of the License at
    6    *
    7    *       http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    *   Unless required by applicable law or agreed to in writing, software
   10    *   distributed under the License is distributed on an "AS IS" BASIS,
   11    *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12    *   See the License for the specific language governing permissions and
   13    *  limitations under the License.
   14    */
   15   
   16   package org.apache.xmlbeans.impl.xpath.saxon;
   17   
   18   import net.sf.saxon.xpath.StandaloneContext;
   19   import net.sf.saxon.Configuration;
   20   import net.sf.saxon.om.NamespaceConstant;
   21   import net.sf.saxon.om.NamePool;
   22   
   23   /**
   24    * Date: Jan 10, 2005
   25    * Time: 10:46:59 AM
   26    * <p/>
   27    * This class is used to circumvent a Saxon limitation,
   28    * namely, the lack of a method to set the default element NS
   29    */
   30   public class XBeansStandaloneContext extends StandaloneContext
   31   {
   32       public XBeansStandaloneContext(Configuration c)
   33       {
   34           super(c);
   35       }
   36   
   37       public XBeansStandaloneContext()
   38       {
   39           super();
   40       }
   41   
   42       public void setDefaultElementNamespace(String uri)
   43       {
   44           defaultUri = true;
   45           defaultNSCode = this.getNamePool().allocateCodeForURI(uri);
   46       }
   47   
   48       public short getDefaultElementNamespace()
   49       {
   50           short result = super.getDefaultElementNamespace();
   51           if (result == NamespaceConstant.NULL_CODE
   52                   && defaultUri)
   53               return (short) defaultNSCode;
   54   
   55           else
   56               return result;
   57       }
   58   
   59       private int defaultNSCode;
   60       private boolean defaultUri;
   61   }

Home » xmlbeans-2.5.0-src » org.apache.xmlbeans.impl.xpath » saxon » [javadoc | source]