/** * Character data */ public void characters(CharSequence chars, Location locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } checkItemType(NodeKindTest.TEXT, nodeSupplier(Type.TEXT, null, chars), locationId); } nextReceiver.characters(chars, locationId, properties); }
private void checkItem(Item item, Location locationId) throws XPathException { TypeHierarchy th = getConfiguration().getTypeHierarchy(); if (!itemType.matches(item, th)) { throwTypeError(null, item, locationId); } }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, Location locationId, int copyNamespaces) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } checkItem(item, locationId); } if (nextReceiver instanceof SequenceReceiver) { nextReceiver.append(item, locationId, copyNamespaces); } else { super.append(item, locationId, copyNamespaces); } }
/** * Character data */ public void characters(CharSequence chars, int locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } ItemType type = NodeKindTest.TEXT; checkItemType(type, locationId); } nextReceiver.characters(chars, locationId, properties); }
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. */ public void process(XPathContext context) throws XPathException { Expression next = operand; int card = StaticProperty.ALLOWS_ZERO_OR_MORE; if (next instanceof CardinalityChecker) { card = ((CardinalityChecker)next).getRequiredCardinality(); next = ((CardinalityChecker)next).getBaseExpression(); } if ((next.getImplementationMethod() & PROCESS_METHOD) != 0 && !(requiredItemType instanceof DocumentNodeTest)) { SequenceReceiver out = context.getReceiver(); TypeCheckingFilter filter = new TypeCheckingFilter(); filter.setUnderlyingReceiver(out); filter.setPipelineConfiguration(out.getPipelineConfiguration()); filter.setRequiredType(requiredItemType, card, role); context.setReceiver(filter); next.process(context); filter.close(); context.setReceiver(out); } else { super.process(context); } }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute * @param typeCode The type of the attribute * @param locationId the location of the node in the source, or of the instruction that created it * @param properties Bit significant value. The following bits are defined: * <dl> * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * </dl> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(NodeName nameCode, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } ItemType type = new CombinedNodeTest( new NameTest(Type.ATTRIBUTE, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ATTRIBUTE, typeCode, getConfiguration(), false)); checkItemType(type, nodeSupplier(Type.ATTRIBUTE, nameCode, value), locationId); } nextReceiver.attribute(nameCode, typeCode, value, locationId, properties); }
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. */ public void process(XPathContext context) throws XPathException { Expression next = getBaseExpression(); int card = StaticProperty.ALLOWS_ZERO_OR_MORE; if (next instanceof CardinalityChecker) { card = ((CardinalityChecker) next).getRequiredCardinality(); next = ((CardinalityChecker) next).getBaseExpression(); } if ((next.getImplementationMethod() & PROCESS_METHOD) != 0 && !(requiredItemType instanceof DocumentNodeTest)) { Receiver out = context.getReceiver(); TypeCheckingFilter filter = new TypeCheckingFilter(out); filter.setRequiredType(requiredItemType, card, role, getLocation()); context.setReceiver(filter); next.process(context); filter.close(); context.setReceiver(out); } else { // Force pull-mode evaluation super.process(context); } }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } checkItemType(Value.asValue(item).getItemType(getConfiguration().getTypeHierarchy()), locationId); } if (nextReceiver instanceof SequenceReceiver) { ((SequenceReceiver)nextReceiver).append(item, locationId, copyNamespaces); } else { super.append(item, locationId, copyNamespaces); } }
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 Supplier<NodeInfo> nodeSupplier(short nodeKind, NodeName name, CharSequence value) { return () -> { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(nodeKind); if (name != null) { o.setNodeName(name); } o.setStringValue(value); return o; }; }
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. */ public void process(XPathContext context) throws XPathException { Expression next = operand; ItemType type = Type.ITEM_TYPE; if (next instanceof ItemChecker) { type = ((ItemChecker)next).getRequiredType(); next = ((ItemChecker)next).getBaseExpression(); } if ((next.getImplementationMethod() & PROCESS_METHOD) != 0 && !(type instanceof DocumentNodeTest)) { SequenceReceiver out = context.getReceiver(); TypeCheckingFilter filter = new TypeCheckingFilter(); filter.setUnderlyingReceiver(out); filter.setPipelineConfiguration(out.getPipelineConfiguration()); filter.setRequiredType(type, requiredCardinality, role); context.setReceiver(filter); next.process(context); filter.close(); context.setReceiver(out); } else { super.process(context); } }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute * @param typeCode The type of the attribute * @param locationId the location of the node in the source, or of the instruction that created it * @param properties Bit significant value. The following bits are defined: * <dl> * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * </dl> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(NodeName nameCode, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } ItemType type = new CombinedNodeTest( new NameTest(Type.ATTRIBUTE, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ATTRIBUTE, typeCode, getConfiguration(), false)); checkItemType(type, nodeSupplier(Type.ATTRIBUTE, nameCode, value), locationId); } nextReceiver.attribute(nameCode, typeCode, value, locationId, properties); }
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. */ public void process(XPathContext context) throws XPathException { Expression next = getBaseExpression(); int card = StaticProperty.ALLOWS_ZERO_OR_MORE; if (next instanceof CardinalityChecker) { card = ((CardinalityChecker) next).getRequiredCardinality(); next = ((CardinalityChecker) next).getBaseExpression(); } if ((next.getImplementationMethod() & PROCESS_METHOD) != 0 && !(requiredItemType instanceof DocumentNodeTest)) { Receiver out = context.getReceiver(); TypeCheckingFilter filter = new TypeCheckingFilter(out); filter.setRequiredType(requiredItemType, card, role, getLocation()); context.setReceiver(filter); next.process(context); filter.close(); context.setReceiver(out); } else { // Force pull-mode evaluation super.process(context); } }
/** * Processing Instruction */ public void processingInstruction(String target, CharSequence data, int locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } ItemType type = NodeKindTest.PROCESSING_INSTRUCTION; checkItemType(type, locationId); } nextReceiver.processingInstruction(target, data, locationId, properties); }
/** * Output an item (atomic value or node) to the sequence */ public void append(Item item, int locationId, int copyNamespaces) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } checkItemType(Value.asValue(item).getItemType(getConfiguration().getTypeHierarchy()), locationId); } if (nextReceiver instanceof SequenceReceiver) { ((SequenceReceiver)nextReceiver).append(item, locationId, copyNamespaces); } else { super.append(item, locationId, copyNamespaces); } }
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 Supplier<NodeInfo> nodeSupplier(short nodeKind, NodeName name, CharSequence value) { return () -> { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(nodeKind); if (name != null) { o.setNodeName(name); } o.setStringValue(value); return o; }; }
/** * Process the instruction, without returning any tail calls * * @param context The dynamic context, giving access to the current node, * the current variables, etc. */ public void process(XPathContext context) throws XPathException { Expression next = operand; int card = StaticProperty.ALLOWS_ZERO_OR_MORE; if (next instanceof CardinalityChecker) { card = ((CardinalityChecker)next).getRequiredCardinality(); next = ((CardinalityChecker)next).getBaseExpression(); } if ((next.getImplementationMethod() & PROCESS_METHOD) != 0 && !(requiredItemType instanceof DocumentNodeTest)) { SequenceReceiver out = context.getReceiver(); TypeCheckingFilter filter = new TypeCheckingFilter(); filter.setUnderlyingReceiver(out); filter.setPipelineConfiguration(out.getPipelineConfiguration()); filter.setRequiredType(requiredItemType, card, role); context.setReceiver(filter); next.process(context); filter.close(); context.setReceiver(out); } else { super.process(context); } }
/** * Notify an attribute. Attributes are notified after the startElement event, and before any * children. Namespaces and attributes may be intermingled. * * @param nameCode The name of the attribute, as held in the name pool * @param typeCode The type of the attribute, as held in the name pool * @param properties Bit significant value. The following bits are defined: * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt> * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt> * @throws IllegalStateException: attempt to output an attribute when there is no open element * start tag */ public void attribute(int nameCode, int typeCode, CharSequence value, int locationId, int properties) throws XPathException { if (level == 0) { if (++count == 2) { checkAllowsMany(locationId); } ItemType type = new CombinedNodeTest( new NameTest(Type.ATTRIBUTE, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ATTRIBUTE, getConfiguration().getSchemaType(typeCode), getConfiguration())); checkItemType(type, locationId); } nextReceiver.attribute(nameCode, typeCode, value, locationId, properties); }
TypeCheckingFilter filter = new TypeCheckingFilter(out); filter.setRequiredType(type, requiredCardinality, role, getLocation()); context.setReceiver(filter); next.process(context); try { filter.close(); } catch (XPathException e) { e.maybeSetLocation(getLocation());