public XSDParserDelegate(Configuration configuration) { handler = new ParserHandler(configuration); }
public void characters(char[] ch, int start, int length) throws SAXException { handler.characters(ch, start, length); }
public void endElement(String uri, String localName, String name) throws SAXException { handler.endElement(uri, localName, name); }
@Override public void element(XMLStreamReader xml, SldTransformContext context) throws XMLStreamException, IOException { try { if (delegate == null && "Filter".equals(xml.getLocalName())) { delegate = new ParserHandler(config(context)); delegate.startDocument(); } if (delegate != null) { delegate.startElement( xml.getNamespaceURI(), xml.getLocalName(), qname(xml.getName()), attributes(xml)); } } catch (SAXException e) { throw new XMLStreamException(e); } }
@Override public void endElement(XMLStreamReader xml, SldTransformContext context) throws XMLStreamException, IOException { if (delegate != null) { try { delegate.endElement( xml.getNamespaceURI(), xml.getLocalName(), qname(xml.getName())); } catch (SAXException e) { throw new XMLStreamException(e); } } if ("Filter".equals(xml.getLocalName())) { Filter filter = (Filter) delegate.getValue(); context.scalar(ECQL.toCQL(filter)).pop(); delegate = null; } }
public Object getParsedObject() { return handler.getValue(); } }
public void endElement(String uri, String localName, String qName) throws SAXException { // pop the last handler off of the stack ElementHandler handler = (ElementHandler) handlers.pop(); // create a qName object from the string String prefix = namespaces.getPrefix(uri); QName qualifiedName = prefix != null ? new QName(uri, localName, prefix) : new QName(uri, localName); handler.endElement(qualifiedName); endElementInternal(handler); // if the upper most delegating handler, then end the document if (handler instanceof DelegatingHandler && !handlers.isEmpty() && !(handlers.peek() instanceof DelegatingHandler)) { DelegatingHandler dh = (DelegatingHandler) handler; dh.endDocument(); // grabbed the parsed value dh.getParseNode().setValue(dh.delegate.getParsedObject()); } // pop namespace context namespaces.popContext(); if (isCDATAEnding()) { setCDATA(false); } }
private Handler getChildHandlerInternal(QName qName) { SchemaIndex index = parser.getSchemaIndex(); parser.getHandlerFactory().createElementHandler(element, this, parser); parser.getHandlerFactory().createElementHandler(element, this, parser);
public ElementHandler createElementHandler(QName qName, Handler parent, ParserHandler parser) { SchemaIndex index = parser.getSchemaIndex(); // look up the element in the schema XSDElementDeclaration element = index.getElementDeclaration(qName); if (element != null) { return createElementHandler(element, parent, parser); } return null; }
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException { handler.startElement(uri, localName, name, atts); }
public void startDocument() throws SAXException { handler.startDocument(); }
public void endDocument() throws SAXException { handler.endDocument(); }
protected void endElementInternal(ElementHandler handler) { super.endElementInternal(handler); if (stream(handler)) { // throw value into buffer buffer.put(handler.getParseNode().getValue()); // remove this node from parse tree if (handler.getParentHandler() instanceof ElementHandler) { ElementHandler parent = (ElementHandler) handler.getParentHandler(); ((NodeImpl) parent.getParseNode()).removeChild(handler.getParseNode()); // parent.endChildHandler(handler); } } }
public void startDocument() throws SAXException { configure(config);
/** * Parses an instance documented defined by a sax input source. * * <p>The object returned from the parse is the object which has been bound to the root element * of the document. This method should only be called once for a single instance document. * * @return The object representation of the root element of the document. * @throws IOException * @throws SAXException * @throws ParserConfigurationException */ public Object parse(InputSource source) throws IOException, SAXException, ParserConfigurationException { parser = parser(); parser.parse(source, handler); return handler.getValue(); }
@Override public ElementHandler createElementHandler(QName qName, Handler parent, ParserHandler parser) { String name = qName.getLocalPart(); if (schemaRegistry.get(name) != null) { // we found a custom schema element // let's treat it as if we've found a placemark SchemaIndex schemaIndex = parser.getSchemaIndex(); XSDElementDeclaration element = schemaIndex.getElementDeclaration(KML.Placemark); if (element != null) { return createElementHandler(element, parent, parser); } } return super.createElementHandler(qName, parent, parser); } }
public void endDocument() throws SAXException { super.endDocument(); buffer.close(); }
return handler.getValue();
@Override public void characters(XMLStreamReader xml, SldTransformContext context) throws XMLStreamException, IOException { if (delegate != null) { try { delegate.characters( xml.getTextCharacters(), xml.getTextStart(), xml.getTextLength()); } catch (SAXException e) { throw new XMLStreamException(e); } } }
/** * Creates a new instance of the parser. * * @param configuration The parser configuration, bindings and context, must never be <code>null * </code>. */ public Parser(Configuration configuration) { if (configuration == null) { throw new NullPointerException("configuration"); } handler = new ParserHandler(configuration); configuration.setupParser(this); }