Refine search
throw new SAXParseException("InputSource needs a stream, reader or URI", null); throw new SAXParseException("Unexpected end of document", null); LocatorImpl locator = new LocatorImpl(); locator.setPublicId(source.getPublicId()); locator.setSystemId(systemId); locator.setLineNumber(ex.getLineNumber()); locator.setColumnNumber(ex.getColumnNumber()); SAXParseException newEx = new SAXParseException(ex.getMessage(), locator);
/** * Copy constructor. * * <p>Create a persistent copy of the current state of a locator. * When the original locator changes, this copy will still keep * the original values (and it can be used outside the scope of * DocumentHandler methods).</p> * * @param locator The locator to copy. */ public LocatorImpl (Locator locator) { setPublicId(locator.getPublicId()); setSystemId(locator.getSystemId()); setLineNumber(locator.getLineNumber()); setColumnNumber(locator.getColumnNumber()); }
m_locator.setColumnNumber(loc.getColumnNumber()); m_locator.setLineNumber(loc.getLineNumber()); m_locator.setPublicId(loc.getPublicId()); m_locator.setSystemId(loc.getSystemId()); m_locator.setColumnNumber(0); m_locator.setLineNumber(0); switch (node.getNodeType()) if (prefix==null) prefix=""; this.m_contentHandler.startPrefixMapping(prefix,uri); final String attrName = attr.getNodeName(); final int colon = attrName.indexOf(':'); final String prefix; prefix = attrName.substring(colon + 1); this.m_contentHandler.startPrefixMapping(prefix, attr.getNodeValue()); String uri = attr.getNamespaceURI(); if (uri != null) this.m_contentHandler.startPrefixMapping(prefix,uri);
protected Locator[] getLocator( SAXParseException spe ) { LocatorImpl loc = new LocatorImpl(); loc.setColumnNumber( spe.getColumnNumber() ); loc.setLineNumber( spe.getLineNumber() ); loc.setSystemId( spe.getSystemId() ); loc.setPublicId( spe.getPublicId() ); return new Locator[]{loc}; }
@Test public void testGenericValidatorContentHandlerErrorThrowsSAXParseException() throws Throwable { SAXParseException ex2 = new SAXParseException("testGenericValidatorContentHandlerParam1", new LocatorImpl()); try { new GenericValidatingPackager().new GenericValidatorContentHandler().error(ex2); fail("Expected SAXParseException to be thrown"); } catch (SAXParseException ex) { assertEquals("ex.getMessage()", "testGenericValidatorContentHandlerParam1", ex.getMessage()); assertNull("ex.getPublicId()", ex.getPublicId()); assertNull("ex.getSystemId()", ex.getSystemId()); assertEquals("ex.getLineNumber()", 0, ex.getLineNumber()); assertEquals("ex.getColumnNumber()", 0, ex.getColumnNumber()); assertNull("ex.getException()", ex.getException()); } }
private Locator extractLocator(SAXParseException e) { LocatorImpl locator = new LocatorImpl(); locator.setSystemId(e.getSystemId()); locator.setLineNumber(e.getLineNumber()); locator.setColumnNumber(e.getColumnNumber()); return locator; }
/** * Constructor. * @param contentHandler The implemention of the * @param systemId System identifier for the document. * contentHandler operation (toXMLString, digest, ...) */ public TreeWalker(ContentHandler contentHandler, DOMHelper dh, String systemId) { this.m_contentHandler = contentHandler; m_contentHandler.setDocumentLocator(m_locator); if (systemId != null) m_locator.setSystemId(systemId); else { try { // Bug see Bugzilla 26741 m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl"); } catch (SecurityException se) {// user.dir not accessible from applet } } m_dh = dh; }
public SAXOutput(ContentHandler out) { this.out = out; out.setDocumentLocator(new LocatorImpl()); }
this.startTag = startTag; if( reader.locator!=null ) // locator could be null, in case of the root state. this.location = new LocatorImpl( reader.locator ); this.baseURI = parentState.baseURI; if( this.baseURI==null ) this.baseURI = reader.locator.getSystemId();
private org.w3c.dom.Document getDomDocument(InputStream inputSource) throws SAXParseException { try { // creating w3c document org.w3c.dom.Document doc = org.netbeans.modules.schema2beans.GraphManager. createXmlDocument(new org.xml.sax.InputSource(inputSource), false, jsfCatalog, new J2eeErrorHandler(this)); return doc; } catch(Exception e) { // XXX Change that throw new SAXParseException(e.getMessage(), new org.xml.sax.helpers.LocatorImpl()); } }
/** * @deprecated * No line number available for the "root" component. */ public Locator getLocator() { LocatorImpl r = new LocatorImpl(); r.setLineNumber(-1); r.setColumnNumber(-1); return r; }
public final @NotNull Locator getLocation() { LocatorImpl loc = new LocatorImpl(); loc.setSystemId(systemId); loc.setLineNumber(lineNumber); return loc; } }
public BeanT createInstance(UnmarshallingContext context) throws IllegalAccessException, InvocationTargetException, InstantiationException, SAXException { BeanT bean = null; if (factoryMethod == null){ bean = ClassFactory.create0(jaxbType); }else { Object o = ClassFactory.create(factoryMethod); if( jaxbType.isInstance(o) ){ bean = (BeanT)o; } else { throw new InstantiationException("The factory method didn't return a correct object"); } } if(xmlLocatorField!=null) // need to copy because Locator is mutable try { xmlLocatorField.set(bean,new LocatorImpl(context.getLocator())); } catch (AccessorException e) { context.handleError(e); } return bean; }
@Override public void handleEvent(@Nullable Event event) { if (event instanceof MutationEvent) { MutationEvent mutationEvent = (MutationEvent) event; EventTarget target = mutationEvent.getTarget(); if (target instanceof Node) { Node node = (Node) target; // Copy the locator. LocatorImpl l = new LocatorImpl(PositionAnnotatingXMLReader.this.locator); // Annotate the node with the copied locator. node.setUserData(XmlUtil.LOCATOR_KEY, l, PositionAnnotatingXMLReader.this.dataHandler); } } } }, true);
/** * Constructor. * @param contentHandler serialHandler The implemention of the SerializationHandler interface */ DOM3TreeWalker( SerializationHandler serialHandler, DOMErrorHandler errHandler, LSSerializerFilter filter, String newLine) { fSerializer = serialHandler; //fErrorHandler = errHandler == null ? new DOMErrorHandlerImpl() : errHandler; // Should we be using the default? fErrorHandler = errHandler; fFilter = filter; fLexicalHandler = null; fNewLine = newLine; fNSBinder = new NamespaceSupport(); fLocalNSBinder = new NamespaceSupport(); fDOMConfigProperties = fSerializer.getOutputFormat(); fSerializer.setDocumentLocator(fLocator); initProperties(fDOMConfigProperties); try { // Bug see Bugzilla 26741 fLocator.setSystemId( System.getProperty("user.dir") + File.separator + "dummy.xsl"); } catch (SecurityException se) { // user.dir not accessible from applet } }
m_locator.setColumnNumber(loc.getColumnNumber()); m_locator.setLineNumber(loc.getLineNumber()); m_locator.setPublicId(loc.getPublicId()); m_locator.setSystemId(loc.getSystemId()); m_locator.setColumnNumber(0); m_locator.setLineNumber(0); switch (node.getNodeType()) String attrName = attr.getNodeName(); ? "" : attrName.substring(index + 1); this.m_contentHandler.startPrefixMapping(prefix, attr.getNodeValue()); if(null == ns) ns = ""; this.m_contentHandler.startElement(ns, m_dh.getLocalNameOfNode(node), node.getNodeName(), this.m_contentHandler.processingInstruction(pi.getNodeName(), pi.getData());
if (node instanceof Locator) { Locator loc = (Locator) node; fLocator.setColumnNumber(loc.getColumnNumber()); fLocator.setLineNumber(loc.getLineNumber()); fLocator.setPublicId(loc.getPublicId()); fLocator.setSystemId(loc.getSystemId()); } else { fLocator.setColumnNumber(0); fLocator.setLineNumber(0); switch (node.getNodeType()) { case Node.DOCUMENT_TYPE_NODE : serializeDocType((DocumentType) node, true);
protected Locator[] getLocator( SAXParseException spe ) { LocatorImpl loc = new LocatorImpl(); loc.setColumnNumber( spe.getColumnNumber() ); loc.setLineNumber( spe.getLineNumber() ); loc.setSystemId( spe.getSystemId() ); loc.setPublicId( spe.getPublicId() ); return new Locator[]{loc}; } }
@Test public void testGenericContentHandlerFatalErrorThrowsSAXParseException() throws Throwable { SAXParseException ex2 = new SAXParseException("testGenericContentHandlerParam1", new LocatorImpl()); try { new GenericPackager().new GenericContentHandler().fatalError(ex2); fail("Expected SAXParseException to be thrown"); } catch (SAXParseException ex) { assertEquals("ex.getMessage()", "testGenericContentHandlerParam1", ex.getMessage()); assertNull("ex.getPublicId()", ex.getPublicId()); assertNull("ex.getSystemId()", ex.getSystemId()); assertEquals("ex.getLineNumber()", 0, ex.getLineNumber()); assertEquals("ex.getColumnNumber()", 0, ex.getColumnNumber()); assertNull("ex.getException()", ex.getException()); } }
/** * Constructor. * @param contentHandler The implemention of the * contentHandler operation (toXMLString, digest, ...) */ public TreeWalker(ContentHandler contentHandler, DOMHelper dh) { this.m_contentHandler = contentHandler; m_contentHandler.setDocumentLocator(m_locator); try { // Bug see Bugzilla 26741 m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl"); } catch (SecurityException se){// user.dir not accessible from applet } m_dh = dh; }