Search in sources :

Example 21 with LocatorImpl

use of org.xml.sax.helpers.LocatorImpl in project robovm by robovm.

the class HandlerBaseTest method testFatalError.

public void testFatalError() {
    // Ordinary case
    try {
        h.fatalError(new SAXParseException("Foo", new LocatorImpl()));
        fail("SAXException expected");
    } catch (SAXException e) {
    // Expected
    }
    // No exception
    try {
        h.fatalError(null);
        fail("NullPointerException expected");
    } catch (SAXException e) {
        fail("NullPointerException expected");
    } catch (NullPointerException e) {
    // Expected
    }
}
Also used : SAXParseException(org.xml.sax.SAXParseException) LocatorImpl(org.xml.sax.helpers.LocatorImpl) SAXException(org.xml.sax.SAXException)

Example 22 with LocatorImpl

use of org.xml.sax.helpers.LocatorImpl in project robovm by robovm.

the class LocatorImplTest method testSetPublicIdGetPublicId.

public void testSetPublicIdGetPublicId() {
    LocatorImpl l = new LocatorImpl();
    l.setPublicId(PUB);
    assertEquals(PUB, l.getPublicId());
    l.setPublicId(null);
    assertEquals(null, l.getPublicId());
}
Also used : LocatorImpl(org.xml.sax.helpers.LocatorImpl)

Example 23 with LocatorImpl

use of org.xml.sax.helpers.LocatorImpl in project OpenAM by OpenRock.

the class MarshallerImpl method write.

private void write(XMLSerializable obj, ContentHandler writer) throws JAXBException {
    try {
        if (getSchemaLocation() != null || getNoNSSchemaLocation() != null) {
            // if we need to add xsi:schemaLocation or its brother,
            // throw in the component to do that.
            writer = new SchemaLocationFilter(getSchemaLocation(), getNoNSSchemaLocation(), writer);
        }
        SAXMarshaller serializer = new SAXMarshaller(writer, prefixMapper, this);
        // set a DocumentLocator that doesn't provide any information
        writer.setDocumentLocator(new LocatorImpl());
        writer.startDocument();
        serializer.childAsBody(obj, null);
        writer.endDocument();
        // extra check
        serializer.reconcileID();
    } catch (SAXException e) {
        throw new MarshalException(e);
    }
}
Also used : SchemaLocationFilter(com.sun.xml.bind.marshaller.SchemaLocationFilter) MarshalException(javax.xml.bind.MarshalException) LocatorImpl(org.xml.sax.helpers.LocatorImpl) SAXException(org.xml.sax.SAXException)

Aggregations

LocatorImpl (org.xml.sax.helpers.LocatorImpl)23 SAXParseException (org.xml.sax.SAXParseException)7 SAXException (org.xml.sax.SAXException)6 SchemaLocationFilter (com.sun.xml.bind.marshaller.SchemaLocationFilter)4 MarshalException (javax.xml.bind.MarshalException)4 IOException (java.io.IOException)3 URL (java.net.URL)3 URLConnection (java.net.URLConnection)3 DocumentImpl (org.apache.harmony.xml.dom.DocumentImpl)3 KXmlParser (org.kxml2.io.KXmlParser)3 DocumentType (org.w3c.dom.DocumentType)3 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)3 Locator (org.xml.sax.Locator)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Properties (java.util.Properties)1 XMLEventReader (javax.xml.stream.XMLEventReader)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 XMLStreamReader (javax.xml.stream.XMLStreamReader)1 XMLEvent (javax.xml.stream.events.XMLEvent)1