src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/DOM2TO.java
changeset 59091 1c071f73949a
parent 47216 71c04702a3d5
equal deleted inserted replaced
59089:de56632f796d 59091:1c071f73949a
     1 /*
     1 /*
     2  * reserved comment block
     2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT REMOVE OR ALTER!
       
     4  */
     3  */
     5 /*
     4 /*
     6  * Licensed to the Apache Software Foundation (ASF) under one or more
     5  * Licensed to the Apache Software Foundation (ASF) under one or more
     7  * contributor license agreements.  See the NOTICE file distributed with
     6  * contributor license agreements.  See the NOTICE file distributed with
     8  * this work for additional information regarding copyright ownership.
     7  * this work for additional information regarding copyright ownership.
    40 import com.sun.org.apache.xml.internal.serializer.NamespaceMappings;
    39 import com.sun.org.apache.xml.internal.serializer.NamespaceMappings;
    41 
    40 
    42 /**
    41 /**
    43  * @author Santiago Pericas-Geertsen
    42  * @author Santiago Pericas-Geertsen
    44  * @author Sunitha Reddy
    43  * @author Sunitha Reddy
       
    44  * @LastModified: Nov 2019
    45  */
    45  */
    46 public class DOM2TO implements XMLReader, Locator2 {
    46 public class DOM2TO implements XMLReader, Locator2 {
    47 
    47 
    48     private final static String EMPTYSTRING = "";
    48     private final static String EMPTYSTRING = "";
    49     private static final String XMLNS_PREFIX = "xmlns";
    49     private static final String XMLNS_PREFIX = "xmlns";
   169                     _handler.namespaceAfterStartElement(prefix, uriAttr);
   169                     _handler.namespaceAfterStartElement(prefix, uriAttr);
   170                 }
   170                 }
   171             }
   171             }
   172 
   172 
   173             // Process all non-namespace attributes next
   173             // Process all non-namespace attributes next
   174             NamespaceMappings nm = new NamespaceMappings();
   174             NamespaceMappings nm = null;
   175             for (int i = 0; i < length; i++) {
   175             for (int i = 0; i < length; i++) {
   176                 final Node attr = map.item(i);
   176                 final Node attr = map.item(i);
   177                 final String qnameAttr = attr.getNodeName();
   177                 final String qnameAttr = attr.getNodeName();
   178 
   178 
   179                 // Is this a regular attribute?
   179                 // Is this a regular attribute?
   185 
   185 
   186                         // Fix for bug 26319
   186                         // Fix for bug 26319
   187                         // For attributes not given an prefix explictly
   187                         // For attributes not given an prefix explictly
   188                         // but having a namespace uri we need
   188                         // but having a namespace uri we need
   189                         // to explicitly generate the prefix
   189                         // to explicitly generate the prefix
       
   190                         if (nm == null) nm = new NamespaceMappings();
   190                         String newPrefix = nm.lookupPrefix(uriAttr);
   191                         String newPrefix = nm.lookupPrefix(uriAttr);
   191                         if (newPrefix == null)
   192                         if (newPrefix == null)
   192                             newPrefix = nm.generateNextPrefix();
   193                             newPrefix = nm.generateNextPrefix();
   193                         prefix = (colon > 0) ? qnameAttr.substring(0, colon)
   194                         prefix = (colon > 0) ? qnameAttr.substring(0, colon)
   194                             : newPrefix;
   195                             : newPrefix;