List of usage examples for org.xml.sax SAXException SAXException
public SAXException(Exception e)
From source file:mf.org.apache.xml.serialize.BaseMarkupSerializer.java
public void notationDecl(String name, String publicId, String systemId) throws SAXException { try {/*w w w . j av a2 s. c o m*/ this._printer.enterDTD(); if (publicId != null) { this._printer.printText("<!NOTATION "); this._printer.printText(name); this._printer.printText(" PUBLIC "); printDoctypeURL(publicId); if (systemId != null) { this._printer.printText(' '); printDoctypeURL(systemId); } } else { this._printer.printText("<!NOTATION "); this._printer.printText(name); this._printer.printText(" SYSTEM "); printDoctypeURL(systemId); } this._printer.printText('>'); if (this._indenting) { this._printer.breakLine(); } } catch (IOException except) { throw new SAXException(except); } }
From source file:net.stuxcrystal.simpledev.configuration.parser.generators.xml.XMLParser.java
/** * Parse the characters of the node./* w ww . j a v a 2 s . co m*/ * @param ch The character array. (Can't we deal with strings?) * @param start The start * @param length The length * @throws SAXException Cannot mix node types. */ @Override public void characters(char ch[], int start, int length) throws SAXException { String content = new String(ch, start, length); if (StringUtils.isBlank(content)) return; NodeContainer container = this.currentStack.peek(); if (!(container.getRawNode() instanceof NullNode) && (!(container.getRawNode() instanceof DataNode))) { throw new SAXException("Node Value already set: " + container.getRawNode().toString()); } if (container.getRawNode() instanceof NullNode) { DataNode node = (DataNode) container.convert(new DataNode()); node.setData(""); } DataNode node = container.getCastedRawNode(); node.setData(node.getData() + content); }
From source file:net.stuxcrystal.simpledev.configuration.parser.generators.xml.XMLParser.java
/** * Actually update the node that is below our current stack. * @param uri PAIN IN THE ASS * @param localName PAIN IN THE ASS * @param qName PAIN IN THE ASS * @throws SAXException Cannot mix node types. *///from ww w . ja v a 2 s .co m @Override public void endElement(String uri, String localName, String qName) throws SAXException { NodeContainer container = this.currentStack.pop(); if (this.currentStack.isEmpty()) { this.base = container.getNode(); } else { NodeContainer parent = this.currentStack.peek(); if (!(parent.getRawNode() instanceof NullNode) && !(parent.getRawNode() instanceof MapNode)) throw new SAXException("The configuration should not mix multiple element types:" + parent.getRawNode().toString()); if (parent.getRawNode() instanceof NullNode) { MapNode base = (MapNode) parent.convert(new MapNode()); base.setData(new Node<?>[0]); } MapNode node = parent.getCastedRawNode(); node.setData((Node<?>[]) ArrayUtils.add(node.getData(), container.getNode())); } }
From source file:net.unicon.academus.apps.XHTMLFilter.java
public void endDocument() throws SAXException { try {/*w w w . j a v a2 s . c o m*/ write('\n'); writer.flush(); } catch (IOException e) { throw new SAXException(e); } }
From source file:net.unicon.academus.apps.XHTMLFilter.java
private void write(String s) throws SAXException { try {/*from ww w . ja v a2s .c o m*/ writer.write(s); } catch (IOException e) { throw new SAXException(e); } }
From source file:net.unicon.academus.apps.XHTMLFilter.java
private void write(char c) throws SAXException { try {/*from w ww.j a v a 2 s. co m*/ writer.write(c); } catch (IOException e) { throw new SAXException(e); } }
From source file:net.yacy.cora.document.feed.RSSReader.java
@Override public void endElement(final String uri, final String name, final String tag) throws SAXException { if (tag == null) return;/*from www . ja va 2s .co m*/ if ("channel".equals(tag) || "feed".equals(tag)) { if (this.parsingChannel) this.theChannel.setChannel(this.item); this.parsingChannel = false; } else if ("item".equals(tag) || "entry".equals(tag)) { this.theChannel.addMessage(this.item); this.parsingItem = false; } else if (this.parsingItem) { final String value = this.buffer.toString().trim(); this.buffer.setLength(0); if (RSSMessage.tags.contains(tag) && value.length() > 0) { this.item.setValue(RSSMessage.valueOfNick(tag), value); } } else if (this.parsingChannel) { final String value = this.buffer.toString().trim(); this.buffer.setLength(0); if (RSSMessage.tags.contains(tag)) this.item.setValue(RSSMessage.valueOfNick(tag), value); } else if (this.type == Type.none) { // give up if we don't known the feed format throw new SAXException("response incomplete or unknown feed format"); } }
From source file:net.yacy.document.parser.xml.GenericXMLContentHandler.java
/** * Try to detect URLs eventually contained in attributes * @throws SAXException when the calling parser reached the maximum bytes limit on the input source *///from ww w. ja v a2s.c o m @Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { this.currentElementText.setLength(0); this.currentElementTextChunks = 0; if (attributes != null) { for (int i = 0; i < attributes.getLength(); i++) { String attribute = attributes.getValue(i); this.detectedURLs += ContentScraper.findAbsoluteURLs(attribute, this.urls, null, this.maxURLs - this.detectedURLs); if (this.detectedURLs >= this.maxURLs) { throw new SAXException( new SizeLimitExceededException("Reached maximum URLs to parse : " + this.maxURLs)); } } } }
From source file:net.yacy.document.parser.xml.GenericXMLContentHandler.java
/** * Perform URLs detection on the ending element text * @throws SAXException when whe maxURLs limit has been reached *///w w w . ja v a 2s .c o m @Override public void endElement(String uri, String localName, String qName) throws SAXException { this.detectedURLs += ContentScraper.findAbsoluteURLs(this.currentElementText.toString(), this.urls, null, this.maxURLs - this.detectedURLs); if (this.detectedURLs >= this.maxURLs) { throw new SAXException( new SizeLimitExceededException("Reached maximum URLs to parse : " + this.maxURLs)); } this.currentElementText.setLength(0); this.currentElementTextChunks = 0; }
From source file:nl.armatiek.xslweb.pipeline.PipelineHandler.java
@Override public void endElement(String uri, String localName, String qName) throws SAXException { try {/*w w w .j a va 2s . c o m*/ if (serializingHandler != null) { serializingHandler.endElement(uri, localName, qName); } if (StringUtils.equals(uri, Definitions.NAMESPACEURI_XSLWEB_PIPELINE)) { if (localName.equals("value")) { ((TransformerStep) pipelineSteps.peek()).getParameters().peek().addValue(chars.toString()); } else if (localName.equals("schema-path")) { ((SchemaValidatorStep) pipelineSteps.peek()).addSchemaPath(chars.toString()); } } else if (StringUtils.equals(uri, Definitions.NAMESPACEURI_XSLWEB_RESPONSE)) { if (localName.equals("response")) { serializingHandler.close(); String response = IOUtils.toString(((ByteArrayOutputStream) os).toByteArray(), "UTF-8"); pipelineSteps.add(new ResponseStep(response, "response", false)); serializingHandler = null; } } chars.setLength(0); } catch (Exception e) { throw new SAXException(e); } }