org.apache.xerces.xni.XNIException Java Examples
The following examples show how to use
org.apache.xerces.xni.XNIException.
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: HtmlUnitNekoHtmlParser.java From htmlunit with Apache License 2.0 | 6 votes |
/** * Extract nested exception within an XNIException (Nekohtml uses reflection and generated * exceptions are wrapped many times within XNIException and InvocationTargetException) * * @param e the original XNIException * @return the cause exception */ static Throwable extractNestedException(final Throwable e) { Throwable originalException = e; Throwable cause = ((XNIException) e).getException(); while (cause != null) { originalException = cause; if (cause instanceof XNIException) { cause = ((XNIException) cause).getException(); } else if (cause instanceof InvocationTargetException) { cause = cause.getCause(); } else { cause = null; } } return originalException; }
Example #2
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 6 votes |
/** Start CDATA section. */ public void startCDATA(Augmentations augs) throws XNIException { fSeenAnything = true; consumeEarlyTextIfNeeded(); // check for end of document if (fSeenRootElementEnd) { return; } // call handler if (fDocumentHandler != null) { fDocumentHandler.startCDATA(augs); } }
Example #3
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 6 votes |
/** Doctype declaration. */ public void doctypeDecl(String rootElementName, String publicId, String systemId, Augmentations augs) throws XNIException { fSeenAnything = true; if (fReportErrors) { if (fSeenRootElement) { fErrorReporter.reportError("HTML2010", null); } else if (fSeenDoctype) { fErrorReporter.reportError("HTML2011", null); } } if (!fSeenRootElement && !fSeenDoctype) { fSeenDoctype = true; if (fDocumentHandler != null) { fDocumentHandler.doctypeDecl(rootElementName, publicId, systemId, augs); } } }
Example #4
Source File: ScriptFilter.java From lams with GNU General Public License v2.0 | 5 votes |
public void characters( XMLString text, Augmentations augs ) throws XNIException { if (_activeScriptBlock != null) { _activeScriptBlock.append( text.ch, text.offset, text.length ); } else { super.characters( text, augs ); } }
Example #5
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** Start entity. */ public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs) throws XNIException { fSeenAnything = true; // check for end of document if (fSeenRootElementEnd) { return; } // insert body, if needed if (!fDocumentFragment) { boolean insertBody = !fSeenRootElement; if (!insertBody) { Info info = fElementStack.peek(); if (info.element.code == HTMLElements.HEAD || info.element.code == HTMLElements.HTML) { String hname = modifyName("head", fNamesElems); String bname = modifyName("body", fNamesElems); if (fReportErrors) { fErrorReporter.reportWarning("HTML2009", new Object[]{hname,bname}); } fQName.setValues(null, hname, hname, null); endElement(fQName, synthesizedAugs()); insertBody = true; } } if (insertBody) { forceStartBody(); } } // call handler if (fDocumentHandler != null) { fDocumentHandler.startGeneralEntity(name, id, encoding, augs); } }
Example #6
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** Empty element. */ public void emptyElement(final QName element, XMLAttributes attrs, Augmentations augs) throws XNIException { startElement(element, attrs, augs); // browser ignore the closing indication for non empty tags like <form .../> but not for unknown element final HTMLElements.Element elem = getElement(element); if (elem.isEmpty() || elem.code == HTMLElements.UNKNOWN) { endElement(element, augs); } }
Example #7
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** * Forces an element start, taking care to set the information to allow startElement to "see" that's * the element has been forced. * @return <code>true</code> if creation could be done (TABLE's creation for instance can't be forced) */ private boolean forceStartElement(final QName elem, XMLAttributes attrs, final Augmentations augs) throws XNIException { forcedStartElement_ = true; startElement(elem, attrs, augs); return fElementStack.top > 0 && elem.equals(fElementStack.peek().qname); }
Example #8
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** Processing instruction. */ public void processingInstruction(String target, XMLString data, Augmentations augs) throws XNIException { fSeenAnything = true; consumeEarlyTextIfNeeded(); if (fDocumentHandler != null) { fDocumentHandler.processingInstruction(target, data, augs); } }
Example #9
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** Comment. */ public void comment(XMLString text, Augmentations augs) throws XNIException { fSeenAnything = true; consumeEarlyTextIfNeeded(); if (fDocumentHandler != null) { fDocumentHandler.comment(text, augs); } }
Example #10
Source File: NekoHtmlDocumentHandler.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void xmlDecl(String arg0, String arg1, String arg2, Augmentations arg3) throws XNIException { if(DEBUG_UNUSED) { Out.println("xmlDecl"); } }
Example #11
Source File: HTMLParser.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** @see DefaultErrorHandler#warning(String,String,XMLParseException) */ @Override public void warning(final String domain, final String key, final XMLParseException exception) throws XNIException { listener_.warning(exception.getMessage(), url_, html_, exception.getLineNumber(), exception.getColumnNumber(), key); }
Example #12
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** End entity. */ public void endGeneralEntity(String name, Augmentations augs) throws XNIException { // check for end of document if (fSeenRootElementEnd) { return; } // call handler if (fDocumentHandler != null) { fDocumentHandler.endGeneralEntity(name, augs); } }
Example #13
Source File: HTMLParser.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void parse(final XMLInputSource inputSource) throws XNIException, IOException { final HtmlUnitDOMBuilder oldBuilder = page_.getBuilder(); page_.setBuilder(this); try { super.parse(inputSource); } finally { page_.setBuilder(oldBuilder); } }
Example #14
Source File: NekoHtmlDocumentHandler.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void endGeneralEntity(String arg0, Augmentations arg1) throws XNIException { if(DEBUG_UNUSED) { Out.println("endGeneralEntity"); } }
Example #15
Source File: HTMLParser.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void startElement(final QName element, final XMLAttributes attributes, final Augmentations augs) throws XNIException { // augs might change so we store only the interesting part lastTagWasSynthesized_ = isSynthesized(augs); super.startElement(element, attributes, augs); }
Example #16
Source File: HTMLSAXParser.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
public void startDocument(XMLLocator arg0, String arg1, NamespaceContext arg2, Augmentations arg3) throws XNIException { super.startDocument(arg0, arg1, arg2, arg3); buffer = new StringBuffer(); }
Example #17
Source File: NekoHtmlDocumentHandler.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void ignorableWhitespace(XMLString arg0, Augmentations arg1) throws XNIException { if(DEBUG_UNUSED) { Out.println("ignorableWhitespace: " + arg0); } }
Example #18
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** Start document. */ public void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs) throws XNIException { // reset state fElementStack.top = 0; if (fragmentContextStack_ != null) { fragmentContextStackSize_ = fragmentContextStack_.length; for (int i=0; i<fragmentContextStack_.length; ++i) { final QName name = fragmentContextStack_[i]; final Element elt = HTMLElements.getElement(name.localpart); fElementStack.push(new Info(elt, name)); } } else { fragmentContextStackSize_ = 0; } fSeenAnything = false; fSeenDoctype = false; fSeenRootElement = false; fSeenRootElementEnd = false; fSeenHeadElement = false; fSeenBodyElement = false; // pass on event if (fDocumentHandler != null) { XercesBridge.getInstance().XMLDocumentHandler_startDocument(fDocumentHandler, locator, encoding, nscontext, augs); } }
Example #19
Source File: HTMLParser.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void endElement(final QName element, final Augmentations augs) throws XNIException { // augs might change so we store only the interesting part lastTagWasSynthesized_ = isSynthesized(augs); super.endElement(element, augs); }
Example #20
Source File: XSLURIResolverExtension.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException { String publicId = resourceIdentifier.getNamespace(); if (XSL_NAMESPACE_URI.equals(publicId)) { String baseLocation = resourceIdentifier.getBaseSystemId(); String xslFilePath = resolve(baseLocation, publicId, null); if (xslFilePath != null) { return new XMLInputSource(publicId, xslFilePath, xslFilePath); } } return null; }
Example #21
Source File: LSPXMLParserConfiguration.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override protected void reset() throws XNIException { super.reset(); if (disableDTDValidation) { // reset again DTD validator by setting "http://xml.org/sax/features/validation" // to false. disableDTDValidation(); } }
Example #22
Source File: XMLCatalogResolverExtension.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException { if (catalogResolver != null) { return catalogResolver.resolveEntity(resourceIdentifier); } return null; }
Example #23
Source File: XMLCacheResolverExtension.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException { String url = resourceIdentifier.getExpandedSystemId(); // Try to get the downloaded resource. In the case where the resource is // downloading but takes too long, a CacheResourceDownloadingException is // thrown. Path file = getCachedResource(url); if (file != null) { // The resource was downloaded locally, use it. return new XMLFileInputSource(resourceIdentifier, file); } return null; }
Example #24
Source File: XSDURIResolverExtension.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException { String publicId = resourceIdentifier.getNamespace(); if (SCHEMA_FOR_SCHEMA_URI_2001.equals(publicId) || SCHEMA_FOR_NAMESPACE_URI_1998.equals(publicId)) { String baseLocation = resourceIdentifier.getBaseSystemId(); String xslFilePath = resolve(baseLocation, publicId, null); if (xslFilePath != null) { return new XMLInputSource(publicId, xslFilePath, xslFilePath); } } return null; }
Example #25
Source File: CMDTDDocument.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public void comment(XMLString text, Augmentations augs) throws XNIException { if (text != null) { comment = text.toString(); } super.comment(text, augs); }
Example #26
Source File: CMDTDDocument.java From lemminx with Eclipse Public License 2.0 | 5 votes |
public void loadInternalDTD(String internalSubset, String baseSystemId, String systemId) throws XNIException, IOException { // Load empty DTD grammar XMLInputSource source = new XMLInputSource("", "", "", new StringReader(""), ""); grammar = (DTDGrammar) loadGrammar(source); // To get the DTD scanner to end at the right place we have to fool // it into thinking that it reached the end of the internal subset // in a real document. fDTDScanner.reset(); StringBuilder buffer = new StringBuilder(internalSubset.length() + 2); buffer.append(internalSubset).append("]>"); XMLInputSource is = new XMLInputSource(null, baseSystemId, null, new StringReader(buffer.toString()), null); fEntityManager.startDocumentEntity(is); fDTDScanner.scanDTDInternalSubset(true, false, systemId != null); }
Example #27
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** Start prefix mapping. */ public void startPrefixMapping(String prefix, String uri, Augmentations augs) throws XNIException { // check for end of document if (fSeenRootElementEnd) { return; } // call handler if (fDocumentHandler != null) { XercesBridge.getInstance().XMLDocumentHandler_startPrefixMapping(fDocumentHandler, prefix, uri, augs); } }
Example #28
Source File: HTMLTagBalancer.java From cc-dbp with Apache License 2.0 | 5 votes |
/** End prefix mapping. */ public void endPrefixMapping(String prefix, Augmentations augs) throws XNIException { // check for end of document if (fSeenRootElementEnd) { return; } // call handler if (fDocumentHandler != null) { XercesBridge.getInstance().XMLDocumentHandler_endPrefixMapping(fDocumentHandler, prefix, augs); } }
Example #29
Source File: CMDTDDocument.java From lemminx with Eclipse Public License 2.0 | 5 votes |
@Override public void attributeDecl(String elementName, String attributeName, String type, String[] enumeration, String defaultType, XMLString defaultValue, XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException { if (comment != null) { nodeInfo = new DTDNodeInfo(); nodeInfo.setComment(comment); attributes.put(attributeName, nodeInfo); } super.attributeDecl(elementName, attributeName, type, enumeration, defaultType, defaultValue, nonNormalizedDefaultValue, augs); }
Example #30
Source File: XSDResolver.java From RISE-V2G with MIT License | 5 votes |
@Override public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, IOException { String literalSystemId = resourceIdentifier.getLiteralSystemId(); if (xmlInputSourceEntities != null && xmlInputSourceEntities.containsKey(literalSystemId)) { return xmlInputSourceEntities.get(literalSystemId); } return null; }