This commit is contained in:
Lana Steuck 2014-09-25 16:20:12 -07:00
commit 5529788824
2 changed files with 18 additions and 18 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -25,10 +25,6 @@
package com.sun.xml.internal.bind.v2.runtime;
import java.io.IOException;
import javax.xml.stream.XMLStreamException;
import com.sun.istack.internal.FinalArrayList;
import com.sun.istack.internal.SAXException2;
@ -36,6 +32,9 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.stream.XMLStreamException;
import java.io.IOException;
/**
* Receives SAX2 events and send the equivalent events to
* {@link XMLSerializer}
@ -70,14 +69,14 @@ final class ContentHandlerAdaptor extends DefaultHandler {
private boolean containsPrefixMapping(String prefix, String uri) {
for( int i=0; i<prefixMap.size(); i+=2 ) {
if(prefixMap.get(i).equals(prefix)
&& prefixMap.get(i+1).equals(uri))
&& prefixMap.get(i+1).equals(uri))
return true;
}
return false;
}
public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
throws SAXException {
throws SAXException {
try {
flushText();
@ -92,13 +91,13 @@ final class ContentHandlerAdaptor extends DefaultHandler {
serializer.startElement(namespaceURI,localName, p,null);
// declare namespace events
for( int i=0; i<prefixMap.size(); i+=2 ) {
for (int i = 0; i < prefixMap.size(); i += 2) {
// forcibly set this binding, instead of using declareNsUri.
// this guarantees that namespaces used in DOM will show up
// as-is in the marshalled output (instead of reassigned to something else,
// which may happen if you'd use declareNsUri.)
serializer.getNamespaceContext().force(
prefixMap.get(i+1), prefixMap.get(i) );
prefixMap.get(i + 1), prefixMap.get(i));
}
// make sure namespaces needed by attributes are bound
for( int i=0; i<len; i++ ) {
@ -108,7 +107,7 @@ final class ContentHandlerAdaptor extends DefaultHandler {
String prefix = getPrefix(qname);
serializer.getNamespaceContext().declareNamespace(
atts.getURI(i), prefix, true );
atts.getURI(i), prefix, true );
}
serializer.endNamespaceDecls(null);
@ -128,9 +127,10 @@ final class ContentHandlerAdaptor extends DefaultHandler {
}
}
// make sure namespaces needed by attributes are bound
private String getPrefix(String qname) {
int idx = qname.indexOf(':');
String prefix = (idx==-1)?qname:qname.substring(0,idx);
String prefix = (idx == -1) ? "" : qname.substring(0, idx);
return prefix;
}

View File

@ -70,7 +70,7 @@ class StAXStreamConnector extends StAXConnector {
// Quick hack until SJSXP fixes 6270116
boolean isZephyr = readerClass.getName().equals("com.sun.xml.internal.stream.XMLReaderImpl");
if (getBoolProp(reader,"org.codehaus.stax2.internNames") &&
getBoolProp(reader,"org.codehaus.stax2.internNsUris"))
getBoolProp(reader,"org.codehaus.stax2.internNsUris"))
; // no need for interning
else
if (isZephyr)
@ -219,8 +219,8 @@ class StAXStreamConnector extends StAXConnector {
int nsCount = staxStreamReader.getNamespaceCount();
for (int i = 0; i < nsCount; i++) {
visitor.startPrefixMapping(
fixNull(staxStreamReader.getNamespacePrefix(i)),
fixNull(staxStreamReader.getNamespaceURI(i)));
fixNull(staxStreamReader.getNamespacePrefix(i)),
fixNull(staxStreamReader.getNamespaceURI(i)));
}
// fire startElement
@ -310,13 +310,13 @@ class StAXStreamConnector extends StAXConnector {
protected void handleCharacters() throws XMLStreamException, SAXException {
if( predictor.expectText() )
buffer.append(
staxStreamReader.getTextCharacters(),
staxStreamReader.getTextStart(),
staxStreamReader.getTextLength() );
staxStreamReader.getTextCharacters(),
staxStreamReader.getTextStart(),
staxStreamReader.getTextLength() );
}
private void processText( boolean ignorable ) throws SAXException {
if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer))) {
if( predictor.expectText() && (!ignorable || !WhiteSpaceProcessor.isWhiteSpace(buffer) || context.getCurrentState().isMixed())) {
if(textReported) {
textReported = false;
} else {