/** * Set the pipeline configuration * @param pipe the pipeline configuration */ public void setPipelineConfiguration(PipelineConfiguration pipe) { this.pipe = pipe; locationProvider = pipe.getLocationProvider(); }
/** * Get the Document Locator */ public LocationProvider getDocumentLocator() { return pipelineConfiguration.getLocationProvider(); } }
/** * Get the Document Locator */ public LocationProvider getDocumentLocator() { return pipelineConfiguration.getLocationProvider(); } }
/** * Set the pipeline configuration * @param pipe the pipeline configuration */ public void setPipelineConfiguration(PipelineConfiguration pipe) { this.pipe = pipe; locationProvider = pipe.getLocationProvider(); }
/** * Notify the start of the event stream */ public void open() throws XPathException { pendingAttributes = new AttributeCollectionImpl(getPipelineConfiguration().getConfiguration()); if (handler == null) { throw new IllegalStateException("ContentHandlerProxy.open(): no underlying handler provided"); } try { locationProvider = getPipelineConfiguration().getLocationProvider(); pendingAttributes.setLocationProvider(locationProvider); Locator locator = new ContentHandlerProxyLocator(this); handler.setDocumentLocator(locator); handler.startDocument(); } catch (SAXException err) { handleSAXException(err); } depth = 0; }
/** * Check that a string consists of valid XML 1.0 characters (UTF-16 encoded) * @param in the string to be checked * @param locationId the location of the string */ private void checkString(CharSequence in, long locationId) throws XPathException { final int len = in.length(); for (int c=0; c<len; c++) { int ch32 = in.charAt(c); if (UTF16.isHighSurrogate(ch32)) { char low = in.charAt(++c); ch32 = UTF16.combinePair((char)ch32, low); } if (!XMLCharacterData.isValid10(ch32)) { XPathException err = new XPathException("The result tree contains a character not allowed by XML 1.0 (hex " + Integer.toHexString(ch32) + ')'); err.setErrorCode("SERE0006"); err.setLocator(new ExpressionLocation(getPipelineConfiguration().getLocationProvider(), locationId)); throw err; } } }
/** * Notify a processing instruction */ public void processingInstruction (String name, CharSequence remainder, int locationId, int properties) { int nameCode = namePool.allocate("", "", name); ProcInstImpl pi = new ProcInstImpl(nameCode, remainder.toString()); currentNode.addChild(pi, size[depth]++); LocationProvider locator = pipe.getLocationProvider(); if (locator!=null) { pi.setLocation(locator.getSystemId(locationId), locator.getLineNumber(locationId)); } }
/** * Notify a processing instruction */ public void processingInstruction (String name, CharSequence remainder, int locationId, int properties) { int nameCode = namePool.allocate("", "", name); ProcInstImpl pi = new ProcInstImpl(nameCode, remainder.toString()); currentNode.addChild(pi, size[depth]++); LocationProvider locator = pipe.getLocationProvider(); if (locator!=null) { pi.setLocation(locator.getSystemId(locationId), locator.getLineNumber(locationId)); } }
/** * Notify a processing instruction */ public void processingInstruction (String name, CharSequence remainder, int locationId, int properties) { int nameCode = namePool.allocate("", "", name); ProcInstImpl pi = new ProcInstImpl(nameCode, remainder.toString()); currentNode.addChild(pi, size[depth]++); LocationProvider locator = pipe.getLocationProvider(); if (locator!=null) { pi.setLocation(locator.getSystemId(locationId), locator.getLineNumber(locationId)); } }
/** * Notify the start of the event stream */ public void open() throws XPathException { pendingAttributes = new AttributeCollectionImpl(getPipelineConfiguration().getConfiguration().getNamePool()); if (handler == null) { throw new IllegalStateException("ContentHandlerProxy.open(): no underlying handler provided"); } try { locationProvider = getPipelineConfiguration().getLocationProvider(); pendingAttributes.setLocationProvider(locationProvider); Locator locator = new ContentHandlerProxyLocator(this); handler.setDocumentLocator(locator); handler.startDocument(); } catch (SAXException err) { handleSAXException(err); } depth = 0; }
/** * Get the Base URI for the node, that is, the URI used for resolving a relative URI contained * in the node. This will be the same as the System ID unless xml:base has been used. * * @return the base URI of the node */ public String getBaseURI() { if (node == null) { // the base URI of a constructed parentless document or element node is the static base URI of the // instruction/expression that created it PipelineConfiguration pipe = savedXPathContext.getController().makePipelineConfiguration(); return pipe.getLocationProvider().getSystemId(instruction.getLocationId()); } else { return node.getBaseURI(); } }
/** * Get the Base URI for the node, that is, the URI used for resolving a relative URI contained * in the node. This will be the same as the System ID unless xml:base has been used. * * @return the base URI of the node */ public String getBaseURI() { if (node == null) { // the base URI of a constructed parentless document or element node is the static base URI of the // instruction/expression that created it PipelineConfiguration pipe = savedXPathContext.getController().makePipelineConfiguration(); return pipe.getLocationProvider().getSystemId(instruction.getLocationId()); } else { return node.getBaseURI(); } }
private void checkAllowsMany(long locationId) throws XPathException { if (!Cardinality.allowsMany(cardinality)) { XPathException err = new XPathException("A sequence of more than one item is not allowed as the " + role.getMessage()); String errorCode = role.getErrorCode(); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } err.setLocator(ExpressionLocation.getSourceLocator(locationId, getPipelineConfiguration().getLocationProvider())); throw err; } }
private void checkAllowsMany(long locationId) throws XPathException { if (!Cardinality.allowsMany(cardinality)) { XPathException err = new XPathException("A sequence of more than one item is not allowed as the " + role.getMessage()); String errorCode = role.getErrorCode(); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } err.setLocator(ExpressionLocation.getSourceLocator(locationId, getPipelineConfiguration().getLocationProvider())); throw err; } }
private void checkItemType(ItemType type, long locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { String message = role.composeErrorMessage(itemType, type, getNamePool()); String errorCode = role.getErrorCode(); XPathException err = new XPathException(message); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } err.setLocator(ExpressionLocation.getSourceLocator(locationId, getPipelineConfiguration().getLocationProvider())); throw err; } }
private void checkItemType(ItemType type, long locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { String message = role.composeErrorMessage(itemType, type, getNamePool()); String errorCode = role.getErrorCode(); XPathException err = new XPathException(message); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } err.setLocator(ExpressionLocation.getSourceLocator(locationId, getPipelineConfiguration().getLocationProvider())); throw err; } }
/** * Processing Instruction */ public void processingInstruction(String target, CharSequence data, int locationId, int properties) throws XPathException { if (!checker.isValidNCName(target)) { XPathException err = new XPathException("Invalid XML 1.0 processing instruction name " + Err.wrap(target)); err.setErrorCode("SERE0005"); err.setLocator(new ExpressionLocation(getPipelineConfiguration().getLocationProvider(), locationId)); throw err; } checkString(data, locationId); nextReceiver.processingInstruction(target, data, locationId, properties); }
/** * Processing Instruction */ public void processingInstruction(String target, CharSequence data, int locationId, int properties) throws XPathException { if (!checker.isValidNCName(target)) { XPathException err = new XPathException("Invalid XML 1.0 processing instruction name " + Err.wrap(target)); err.setErrorCode("SERE0005"); err.setLocator(new ExpressionLocation(getPipelineConfiguration().getLocationProvider(), locationId)); throw err; } checkString(data, locationId); nextReceiver.processingInstruction(target, data, locationId, properties); }
/** * Notify the start of an element * * @param nameCode integer code identifying the name of the element within the name pool. * @param typeCode integer code identifying the element's type within the name pool. * @param properties properties of the element node */ public void startElement(int nameCode, int typeCode, int locationId, int properties) throws XPathException { if (!cache.contains(nameCode)) { if (!checker.isValidNCName(pool.getLocalName(nameCode))) { XPathException err = new XPathException("Invalid XML 1.0 element name " + Err.wrap(pool.getLocalName(nameCode), Err.ELEMENT)); err.setErrorCode("SERE0005"); err.setLocator(new ExpressionLocation(getPipelineConfiguration().getLocationProvider(), locationId)); throw err; } cache.add(nameCode); } nextReceiver.startElement(nameCode, typeCode, locationId, properties); }
/** * Notify the start of an element * * @param nameCode integer code identifying the name of the element within the name pool. * @param typeCode integer code identifying the element's type within the name pool. * @param properties properties of the element node */ public void startElement(int nameCode, int typeCode, int locationId, int properties) throws XPathException { if (!cache.contains(nameCode)) { if (!checker.isValidNCName(pool.getLocalName(nameCode))) { XPathException err = new XPathException("Invalid XML 1.0 element name " + Err.wrap(pool.getLocalName(nameCode), Err.ELEMENT)); err.setErrorCode("SERE0005"); err.setLocator(new ExpressionLocation(getPipelineConfiguration().getLocationProvider(), locationId)); throw err; } cache.add(nameCode); } nextReceiver.startElement(nameCode, typeCode, locationId, properties); }