private void checkItemType(ItemType type, Supplier<? extends Item<?>> itemSupplier, Location locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { throwTypeError(type, itemSupplier == null ? null : itemSupplier.get(), locationId); } }
private void checkItemType(ItemType type, Supplier<? extends Item<?>> itemSupplier, Location locationId) throws XPathException { if (!getConfiguration().getTypeHierarchy().isSubType(type, itemType)) { throwTypeError(type, itemSupplier == null ? null : itemSupplier.get(), locationId); } }
private void checkItem(Item item, Location locationId) throws XPathException { TypeHierarchy th = getConfiguration().getTypeHierarchy(); if (!itemType.matches(item, th)) { throwTypeError(null, item, locationId); } }
private void checkItem(Item item, Location locationId) throws XPathException { TypeHierarchy th = getConfiguration().getTypeHierarchy(); if (!itemType.matches(item, th)) { throwTypeError(null, item, locationId); } }
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; }; }
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; }; }
new NameTest(Type.ELEMENT, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, getConfiguration().getSchemaType(typeCode), getConfiguration())); checkItemType(type, locationId); } else { new NameTest(Type.ELEMENT, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, getConfiguration().getSchemaType(typeCode), getConfiguration())); checkItemType(type, locationId); checkedElements.add(key);
new NameTest(Type.ELEMENT, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, getConfiguration().getSchemaType(typeCode), getConfiguration())); checkItemType(type, locationId); } else { new NameTest(Type.ELEMENT, nameCode, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, getConfiguration().getSchemaType(typeCode), getConfiguration())); checkItemType(type, locationId); checkedElements.add(key);
/** * 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); }
/** * 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); }
/** * 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); } }
/** * 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 void throwTypeError(ItemType suppliedType, Item item, Location locationId) throws XPathException { String message; TypeHierarchy th = getConfiguration().getTypeHierarchy(); if (item == null) { message = role.composeErrorMessage(itemType, suppliedType); } else { message = role.composeErrorMessage(itemType, item, th); } String errorCode = role.getErrorCode(); XPathException err = new XPathException(message); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } if (locationId == null) { err.setLocation(locator); } else { err.setLocation(locationId.saveLocation()); } 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 throwTypeError(ItemType suppliedType, Item item, Location locationId) throws XPathException { String message; TypeHierarchy th = getConfiguration().getTypeHierarchy(); if (item == null) { message = role.composeErrorMessage(itemType, suppliedType); } else { message = role.composeErrorMessage(itemType, item, th); } String errorCode = role.getErrorCode(); XPathException err = new XPathException(message); err.setErrorCode(errorCode); if (!"XPDY0050".equals(errorCode)) { err.setIsTypeError(true); } if (locationId == null) { err.setLocation(locator); } else { err.setLocation(locationId.saveLocation()); } throw err; }
new NameTest(Type.ELEMENT, nodeName, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, typeCode, getConfiguration(), false)); checkItemType(type, nodeSupplier(Type.ELEMENT, nodeName, ""), location); } else { new NameTest(Type.ELEMENT, nodeName, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, typeCode, getConfiguration(), false)); checkItemType(type, nodeSupplier(Type.ELEMENT, nodeName, ""), location); checkedElements.add(key);
new NameTest(Type.ELEMENT, nodeName, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, typeCode, getConfiguration(), false)); checkItemType(type, nodeSupplier(Type.ELEMENT, nodeName, ""), location); } else { new NameTest(Type.ELEMENT, nodeName, getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, typeCode, getConfiguration(), false)); checkItemType(type, nodeSupplier(Type.ELEMENT, nodeName, ""), location); checkedElements.add(key);
/** * 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); }
/** * 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); }