< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xml/internal/dtm/ref/sax2dtm/SAX2DTM2.java
Print this page
rev 1063 : 8172974: [JAXP] XALAN: Wrong result when transforming namespace unaware StAX Input
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -2022,15 +2022,22 @@
charactersFlush();
// in case URI and localName are empty, the input is not using the
// namespaces feature. Then we should take the part after the last
// colon of qName as localName (strip all namespace prefixes)
- if ((uri == null || uri.isEmpty()) &&
- (localName == null || localName.isEmpty()))
- {
- final int colon = qName.lastIndexOf(':');
- localName = (colon > -1) ? qName.substring(colon + 1) : qName;
+ // When the URI is empty but localName has colons then we can also
+ // assume non namespace aware and prefixes can be stripped
+ if (uri == null || uri.isEmpty()) {
+ if (localName == null || localName.isEmpty()) {
+ final int colon = qName.lastIndexOf(':');
+ localName = (colon > -1) ? qName.substring(colon + 1) : qName;
+ } else {
+ final int colon = localName.lastIndexOf(':');
+ if (colon > -1) {
+ localName = localName.substring(colon + 1);
+ }
+ }
}
int exName = m_expandedNameTable.getExpandedTypeID(uri, localName,
DTM.ELEMENT_NODE);
@@ -2096,11 +2103,13 @@
if (attrLocalName == null || attrLocalName.isEmpty()) {
final int colon = attrQName.lastIndexOf(':');
attrLocalName = (colon > -1) ? attrQName.substring(colon + 1) : attrQName;
} else {
final int colon = attrLocalName.lastIndexOf(':');
- attrLocalName = (colon > -1) ? attrLocalName.substring(colon + 1) : attrLocalName;
+ if (colon > -1) {
+ attrLocalName = attrLocalName.substring(colon + 1);
+ }
}
}
int nodeType;
if ((null != attrQName) &&
< prev index next >