本文整理汇总了Java中org.xml.sax.ContentHandler.setDocumentLocator方法的典型用法代码示例。如果您正苦于以下问题:Java ContentHandler.setDocumentLocator方法的具体用法?Java ContentHandler.setDocumentLocator怎么用?Java ContentHandler.setDocumentLocator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xml.sax.ContentHandler
的用法示例。
在下文中一共展示了ContentHandler.setDocumentLocator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeTo
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
/**
* 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");
}
示例2: writeTo
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
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");
}
}
示例3: startForking
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
/**
* 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);
}
示例4: SAXOutput
import org.xml.sax.ContentHandler; //导入方法依赖的package包/类
public SAXOutput(ContentHandler out) {
this.out = out;
out.setDocumentLocator(new LocatorImpl());
}