Java Code Examples for org.xml.sax.ContentHandler#startPrefixMapping()

The following examples show how to use org.xml.sax.ContentHandler#startPrefixMapping() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProblemActionHeader.java    From jdk8u60 with GNU General Public License v2.0 8 votes vote down vote up
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException {
    String nsUri = getNamespaceURI();
    String ln = getLocalPart();

    h.startPrefixMapping("",nsUri);
    h.startElement(nsUri,ln,ln,EMPTY_ATTS);
    h.startElement(nsUri,actionLocalName,actionLocalName,EMPTY_ATTS);
    h.characters(action.toCharArray(),0,action.length());
    h.endElement(nsUri,actionLocalName,actionLocalName);
    if (soapAction != null) {
        h.startElement(nsUri,soapActionLocalName,soapActionLocalName,EMPTY_ATTS);
        h.characters(soapAction.toCharArray(),0,soapAction.length());
        h.endElement(nsUri,soapActionLocalName,soapActionLocalName);
    }
    h.endElement(nsUri,ln,ln);
}
 
Example 2
Source File: ProblemActionHeader.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException {
    String nsUri = getNamespaceURI();
    String ln = getLocalPart();

    h.startPrefixMapping("",nsUri);
    h.startElement(nsUri,ln,ln,EMPTY_ATTS);
    h.startElement(nsUri,actionLocalName,actionLocalName,EMPTY_ATTS);
    h.characters(action.toCharArray(),0,action.length());
    h.endElement(nsUri,actionLocalName,actionLocalName);
    if (soapAction != null) {
        h.startElement(nsUri,soapActionLocalName,soapActionLocalName,EMPTY_ATTS);
        h.characters(soapAction.toCharArray(),0,soapAction.length());
        h.endElement(nsUri,soapActionLocalName,soapActionLocalName);
    }
    h.endElement(nsUri,ln,ln);
}
 
Example 3
Source File: ProblemActionHeader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException {
    String nsUri = getNamespaceURI();
    String ln = getLocalPart();

    h.startPrefixMapping("",nsUri);
    h.startElement(nsUri,ln,ln,EMPTY_ATTS);
    h.startElement(nsUri,actionLocalName,actionLocalName,EMPTY_ATTS);
    h.characters(action.toCharArray(),0,action.length());
    h.endElement(nsUri,actionLocalName,actionLocalName);
    if (soapAction != null) {
        h.startElement(nsUri,soapActionLocalName,soapActionLocalName,EMPTY_ATTS);
        h.characters(soapAction.toCharArray(),0,soapAction.length());
        h.endElement(nsUri,soapActionLocalName,soapActionLocalName);
    }
    h.endElement(nsUri,ln,ln);
}
 
Example 4
Source File: ProblemActionHeader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException {
    String nsUri = getNamespaceURI();
    String ln = getLocalPart();

    h.startPrefixMapping("",nsUri);
    h.startElement(nsUri,ln,ln,EMPTY_ATTS);
    h.startElement(nsUri,actionLocalName,actionLocalName,EMPTY_ATTS);
    h.characters(action.toCharArray(),0,action.length());
    h.endElement(nsUri,actionLocalName,actionLocalName);
    if (soapAction != null) {
        h.startElement(nsUri,soapActionLocalName,soapActionLocalName,EMPTY_ATTS);
        h.characters(soapAction.toCharArray(),0,soapAction.length());
        h.endElement(nsUri,soapActionLocalName,soapActionLocalName);
    }
    h.endElement(nsUri,ln,ln);
}
 
Example 5
Source File: AbstractMessageImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Writes the whole envelope as SAX events.
 */
@Override
public void writeTo( ContentHandler contentHandler, ErrorHandler errorHandler ) throws SAXException {
    String soapNsUri = soapVersion.nsUri;

    contentHandler.setDocumentLocator(NULL_LOCATOR);
    contentHandler.startDocument();
    contentHandler.startPrefixMapping("S",soapNsUri);
    contentHandler.startElement(soapNsUri,"Envelope","S:Envelope",EMPTY_ATTS);
    if(hasHeaders()) {
        contentHandler.startElement(soapNsUri,"Header","S:Header",EMPTY_ATTS);
        MessageHeaders headers = getHeaders();
        for (Header h : headers.asList()) {
            h.writeTo(contentHandler,errorHandler);
        }
        contentHandler.endElement(soapNsUri,"Header","S:Header");
    }
    // write the body
    contentHandler.startElement(soapNsUri,"Body","S:Body",EMPTY_ATTS);
    writePayloadTo(contentHandler,errorHandler, true);
    contentHandler.endElement(soapNsUri,"Body","S:Body");
    contentHandler.endElement(soapNsUri,"Envelope","S:Envelope");
}
 
Example 6
Source File: ProblemActionHeader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException {
    String nsUri = getNamespaceURI();
    String ln = getLocalPart();

    h.startPrefixMapping("",nsUri);
    h.startElement(nsUri,ln,ln,EMPTY_ATTS);
    h.startElement(nsUri,actionLocalName,actionLocalName,EMPTY_ATTS);
    h.characters(action.toCharArray(),0,action.length());
    h.endElement(nsUri,actionLocalName,actionLocalName);
    if (soapAction != null) {
        h.startElement(nsUri,soapActionLocalName,soapActionLocalName,EMPTY_ATTS);
        h.characters(soapAction.toCharArray(),0,soapAction.length());
        h.endElement(nsUri,soapActionLocalName,soapActionLocalName);
    }
    h.endElement(nsUri,ln,ln);
}
 
Example 7
Source File: ForkContentHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public void startPrefixMapping(String prefix, String uri) throws SAXException {
   ContentHandler[] arr$ = this.handlers;
   int len$ = arr$.length;

   for(int i$ = 0; i$ < len$; ++i$) {
      ContentHandler handler = arr$[i$];
      handler.startPrefixMapping(prefix, uri);
   }

}
 
Example 8
Source File: SAAJMessage.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Collects the ns declarations and starts the prefix mapping, consequently the associated endPrefixMapping needs to be called.
 * @param contentHandler
 * @param attrs
 * @param excludePrefix , this is to excldue the global prefix mapping "S" used at the start
 * @throws SAXException
 */
private void startPrefixMapping(ContentHandler contentHandler, NamedNodeMap attrs, String excludePrefix) throws SAXException {
    if(attrs == null)
        return;
    for(int i=0; i < attrs.getLength();i++) {
        Attr a = (Attr)attrs.item(i);
        //check if attr is ns declaration
        if("xmlns".equals(a.getPrefix()) || "xmlns".equals(a.getLocalName())) {
            if(!fixNull(a.getPrefix()).equals(excludePrefix)) {
                contentHandler.startPrefixMapping(fixNull(a.getPrefix()), a.getNamespaceURI());
            }
        }
    }
}
 
Example 9
Source File: SAAJMessage.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example 10
Source File: ForkingFilter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Starts the event forking.
 */
public void startForking(String uri, String localName, String qName, Attributes atts, ContentHandler side) throws SAXException {
    if(this.side!=null)     throw new IllegalStateException();  // can't fork to two handlers

    this.side = side;
    depth = 1;
    side.setDocumentLocator(loc);
    side.startDocument();
    for( int i=0; i<namespaces.size(); i+=2 )
        side.startPrefixMapping(namespaces.get(i),namespaces.get(i+1));
    side.startElement(uri,localName,qName,atts);
}
 
Example 11
Source File: SAAJMessage.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example 12
Source File: StringHeader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException {
    String nsUri = name.getNamespaceURI();
    String ln = name.getLocalPart();

    h.startPrefixMapping("",nsUri);
    if(mustUnderstand) {
        AttributesImpl attributes = new AttributesImpl();
        attributes.addAttribute(soapVersion.nsUri,MUST_UNDERSTAND,"S:"+MUST_UNDERSTAND,"CDATA", getMustUnderstandLiteral(soapVersion));
        h.startElement(nsUri,ln,ln,attributes);
    } else {
        h.startElement(nsUri,ln,ln,EMPTY_ATTS);
    }
    h.characters(value.toCharArray(),0,value.length());
    h.endElement(nsUri,ln,ln);
}
 
Example 13
Source File: FaultDetailHeader.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler h, ErrorHandler errorHandler) throws SAXException {
    String nsUri = av.nsUri;
    String ln = av.faultDetailTag.getLocalPart();

    h.startPrefixMapping("",nsUri);
    h.startElement(nsUri,ln,ln,EMPTY_ATTS);
    h.startElement(nsUri,wrapper,wrapper,EMPTY_ATTS);
    h.characters(problemValue.toCharArray(),0,problemValue.length());
    h.endElement(nsUri,wrapper,wrapper);
    h.endElement(nsUri,ln,ln);
}
 
Example 14
Source File: ForkContentHandler.java    From freehealth-connector with GNU Affero General Public License v3.0 5 votes vote down vote up
public void startPrefixMapping(String prefix, String uri) throws SAXException {
   ContentHandler[] arr$ = this.handlers;
   int len$ = arr$.length;

   for(int i$ = 0; i$ < len$; ++i$) {
      ContentHandler handler = arr$[i$];
      handler.startPrefixMapping(prefix, uri);
   }

}
 
Example 15
Source File: SAAJMessage.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example 16
Source File: ForkingFilter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Starts the event forking.
 */
public void startForking(String uri, String localName, String qName, Attributes atts, ContentHandler side) throws SAXException {
    if(this.side!=null)     throw new IllegalStateException();  // can't fork to two handlers

    this.side = side;
    depth = 1;
    side.setDocumentLocator(loc);
    side.startDocument();
    for( int i=0; i<namespaces.size(); i+=2 )
        side.startPrefixMapping(namespaces.get(i),namespaces.get(i+1));
    side.startElement(uri,localName,qName,atts);
}
 
Example 17
Source File: SAAJMessage.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
    String soapNsUri = soapVersion.nsUri;
    if (!parsedMessage) {
        DOMScanner ds = new DOMScanner();
        ds.setContentHandler(contentHandler);
        ds.scan(sm.getSOAPPart());
    } else {
        contentHandler.setDocumentLocator(NULL_LOCATOR);
        contentHandler.startDocument();
        contentHandler.startPrefixMapping("S", soapNsUri);
        startPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.startElement(soapNsUri, "Envelope", "S:Envelope", getAttributes(envelopeAttrs));
        if (hasHeaders()) {
            startPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.startElement(soapNsUri, "Header", "S:Header", getAttributes(headerAttrs));
            MessageHeaders headers = getHeaders();
            for (Header h : headers.asList()) {
                h.writeTo(contentHandler, errorHandler);
            }
            endPrefixMapping(contentHandler, headerAttrs,"S");
            contentHandler.endElement(soapNsUri, "Header", "S:Header");

        }
        startPrefixMapping(contentHandler, bodyAttrs,"S");
        // write the body
        contentHandler.startElement(soapNsUri, "Body", "S:Body", getAttributes(bodyAttrs));
        writePayloadTo(contentHandler, errorHandler, true);
        endPrefixMapping(contentHandler, bodyAttrs,"S");
        contentHandler.endElement(soapNsUri, "Body", "S:Body");
        endPrefixMapping(contentHandler, envelopeAttrs,"S");
        contentHandler.endElement(soapNsUri, "Envelope", "S:Envelope");
    }
}
 
Example 18
Source File: SAXEventBuffer.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
private void sendStartPrefixMapping(ContentHandler handler, boolean release) throws SAXException {
	String nsUri = nextString(release);
	String nsPrefix = nextString(release);
	if (nsPrefix == null)
		nsPrefix = XMLConstants.DEFAULT_NS_PREFIX;

	handler.startPrefixMapping(nsPrefix, nsUri);

	pushTmpString(nsPrefix);
	pushTmpString(END_PREFIX_MAPPING);								
}
 
Example 19
Source File: TagInfoset.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes the start element event.
 */
public void writeStart(ContentHandler contentHandler) throws SAXException {
    for( int i=0; i<ns.length; i+=2 )
        contentHandler.startPrefixMapping(fixNull(ns[i]),fixNull(ns[i+1]));
    contentHandler.startElement(fixNull(nsUri), localName ,getQName(), atts);
}
 
Example 20
Source File: TagInfoset.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Writes the start element event.
 */
public void writeStart(ContentHandler contentHandler) throws SAXException {
    for( int i=0; i<ns.length; i+=2 )
        contentHandler.startPrefixMapping(fixNull(ns[i]),fixNull(ns[i+1]));
    contentHandler.startElement(fixNull(nsUri), localName ,getQName(), atts);
}