< prev index next >

src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2StAXEventWriter.java

Print this page


   1 /*
   2  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * @LastModified: Oct 2017
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.  Oracle designates this
   9  * particular file as subject to the "Classpath" exception as provided
  10  * by Oracle in the LICENSE file that accompanied this code.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  23  * or visit www.oracle.com if you need additional information or have any


 320         } catch (XMLStreamException e) {
 321 
 322             throw new SAXException(e);
 323 
 324         }
 325 
 326         super.endCDATA();
 327 
 328     }
 329 
 330     @SuppressWarnings({"rawtypes", "unchecked"})
 331     protected void createStartEvents(Attributes attributes, Collection<Attribute>[] events) {
 332 
 333         Map<String, Attribute> nsMap = null;
 334         List<Attribute> attrs = null;
 335 
 336         // create namespaces
 337         if (namespaces != null) {
 338             final int nDecls = namespaces.size();
 339             for (int i = 0; i < nDecls; i++) {
 340                 final String prefix = (String) namespaces.get(i++);
 341                 String uri = (String) namespaces.get(i);
 342                 Namespace ns = createNamespace(prefix, uri);
 343                 if (nsMap == null) {
 344                     nsMap = new HashMap<>();
 345                 }
 346                 nsMap.put(prefix, ns);
 347             }
 348         }
 349 
 350         // create attributes
 351         String[] qname = {null, null};
 352         for (int i = 0, s = attributes.getLength(); i < s; i++) {
 353 
 354             parseQName(attributes.getQName(i), qname);
 355 
 356             String attrPrefix = qname[0];
 357             String attrLocal = qname[1];
 358 
 359             String attrQName = attributes.getQName(i);
 360             String attrValue = attributes.getValue(i);
 361             String attrURI = attributes.getURI(i);


   1 /*
   2  * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.

   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 319         } catch (XMLStreamException e) {
 320 
 321             throw new SAXException(e);
 322 
 323         }
 324 
 325         super.endCDATA();
 326 
 327     }
 328 
 329     @SuppressWarnings({"rawtypes", "unchecked"})
 330     protected void createStartEvents(Attributes attributes, Collection<Attribute>[] events) {
 331 
 332         Map<String, Attribute> nsMap = null;
 333         List<Attribute> attrs = null;
 334 
 335         // create namespaces
 336         if (namespaces != null) {
 337             final int nDecls = namespaces.size();
 338             for (int i = 0; i < nDecls; i++) {
 339                 final String prefix = namespaces.get(i++);
 340                 String uri = namespaces.get(i);
 341                 Namespace ns = createNamespace(prefix, uri);
 342                 if (nsMap == null) {
 343                     nsMap = new HashMap<>();
 344                 }
 345                 nsMap.put(prefix, ns);
 346             }
 347         }
 348 
 349         // create attributes
 350         String[] qname = {null, null};
 351         for (int i = 0, s = attributes.getLength(); i < s; i++) {
 352 
 353             parseQName(attributes.getQName(i), qname);
 354 
 355             String attrPrefix = qname[0];
 356             String attrLocal = qname[1];
 357 
 358             String attrQName = attributes.getQName(i);
 359             String attrValue = attributes.getValue(i);
 360             String attrURI = attributes.getURI(i);


< prev index next >