/** * Decide whether an element is in the set of white-space preserving element types * * @param name identifies the name of the element being tested * @param schemaType the type annotation of the element being tested * @return STRIP_DEFAULT: strip spaces unless xml:space tells you not to. */ public int isSpacePreserving(NodeName name, SchemaType schemaType) { if (schemaType != Untyped.getInstance() && schemaType.isComplexType() && !((ComplexType) schemaType).isSimpleContent() && !((ComplexType) schemaType).isMixedContent()) { return Stripper.ALWAYS_STRIP; } else { return Stripper.ALWAYS_PRESERVE; } }
/** * Decide whether an element is in the set of white-space preserving element types * * @param name identifies the name of the element being tested * @param schemaType the type annotation of the element being tested * @return STRIP_DEFAULT: strip spaces unless xml:space tells you not to. */ public int isSpacePreserving(NodeName name, SchemaType schemaType) { if (schemaType != Untyped.getInstance() && schemaType.isComplexType() && !((ComplexType) schemaType).isSimpleContent() && !((ComplexType) schemaType).isMixedContent()) { return Stripper.ALWAYS_STRIP; } else { return Stripper.ALWAYS_PRESERVE; } }
public void startElement(NodeName nameCode, SchemaType type, Location location, int properties) throws XPathException { //System.err.println("startElement " + getNamePool().getDisplayName(nameCode)); nextReceiver.startElement(nameCode, type, location, properties); boolean strip = false; if (type != Untyped.getInstance()) { // if the element has element-only content, whitespace stripping is enabled if (type.isComplexType() && !((ComplexType) type).isSimpleContent() && !((ComplexType) type).isMixedContent()) { strip = true; } } //System.err.println("strip = " + strip); // put "strip" value on top of stack top++; if (top >= stripStack.length) { stripStack = Arrays.copyOf(stripStack, top*2); } stripStack[top] = strip; }
public void startElement(NodeName nameCode, SchemaType type, Location location, int properties) throws XPathException { //System.err.println("startElement " + getNamePool().getDisplayName(nameCode)); nextReceiver.startElement(nameCode, type, location, properties); boolean strip = false; if (type != Untyped.getInstance()) { // if the element has element-only content, whitespace stripping is enabled if (type.isComplexType() && !((ComplexType) type).isSimpleContent() && !((ComplexType) type).isMixedContent()) { strip = true; } } //System.err.println("strip = " + strip); // put "strip" value on top of stack top++; if (top >= stripStack.length) { stripStack = Arrays.copyOf(stripStack, top*2); } stripStack[top] = strip; }
public void startElement(NodeName elemName, SchemaType type, Location location, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(elemName, type, location, properties); byte preserveParent = stripStack[top]; byte preserve = (byte) (preserveParent & (PRESERVE_PARENT | ASSERTIONS_EXIST)); int elementStrip = isSpacePreserving(elemName, type); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (type != Untyped.getInstance()) { if (preserve == 0) { // if the element has simple content, whitespace stripping is disabled if (type.isSimpleType() || ((ComplexType) type).isSimpleContent()) { preserve |= SIMPLE_CONTENT; } } if (type instanceof ComplexType && ((ComplexType) type).hasAssertions()) { preserve |= ASSERTIONS_EXIST; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { stripStack = Arrays.copyOf(stripStack, top * 2); } stripStack[top] = preserve; }
public void startElement(NodeName elemName, SchemaType type, Location location, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(elemName, type, location, properties); byte preserveParent = stripStack[top]; byte preserve = (byte) (preserveParent & (PRESERVE_PARENT | ASSERTIONS_EXIST)); int elementStrip = isSpacePreserving(elemName, type); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (type != Untyped.getInstance()) { if (preserve == 0) { // if the element has simple content, whitespace stripping is disabled if (type.isSimpleType() || ((ComplexType) type).isSimpleContent()) { preserve |= SIMPLE_CONTENT; } } if (type instanceof ComplexType && ((ComplexType) type).hasAssertions()) { preserve |= ASSERTIONS_EXIST; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { stripStack = Arrays.copyOf(stripStack, top * 2); } stripStack[top] = preserve; }
public void startElement (int nameCode, int typeCode, int locationId, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(nameCode, typeCode, locationId, properties); byte preserveParent = stripStack[top]; byte preserve = (byte)(preserveParent & PRESERVE_PARENT); byte elementStrip = isSpacePreserving(nameCode); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (preserve == 0 && typeCode != -1 && typeCode != StandardNames.XS_UNTYPED) { // if the element has simple content, whitespace stripping is disabled SchemaType type = getConfiguration().getSchemaType(typeCode); if (type.isSimpleType() || ((ComplexType)type).isSimpleContent()) { preserve |= CANNOT_STRIP; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { byte[] newStack = new byte[top*2]; System.arraycopy(stripStack, 0, newStack, 0, top); stripStack = newStack; } stripStack[top] = preserve; }
public void startElement (int nameCode, int typeCode, int locationId, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(nameCode, typeCode, locationId, properties); byte preserveParent = stripStack[top]; byte preserve = (byte)(preserveParent & PRESERVE_PARENT); byte elementStrip = isSpacePreserving(nameCode); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (preserve == 0 && typeCode != -1 && typeCode != StandardNames.XS_UNTYPED) { // if the element has simple content, whitespace stripping is disabled SchemaType type = getConfiguration().getSchemaType(typeCode); if (type.isSimpleType() || ((ComplexType)type).isSimpleContent()) { preserve |= CANNOT_STRIP; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { byte[] newStack = new byte[top*2]; System.arraycopy(stripStack, 0, newStack, 0, top); stripStack = newStack; } stripStack[top] = preserve; }
public void startElement (int nameCode, int typeCode, int locationId, int properties) throws XPathException { // System.err.println("startElement " + nameCode); nextReceiver.startElement(nameCode, typeCode, locationId, properties); byte preserveParent = stripStack[top]; byte preserve = (byte)(preserveParent & PRESERVE_PARENT); byte elementStrip = isSpacePreserving(nameCode); if (elementStrip == ALWAYS_PRESERVE) { preserve |= ALWAYS_PRESERVE; } else if (elementStrip == ALWAYS_STRIP) { preserve |= ALWAYS_STRIP; } if (preserve == 0 && typeCode != -1 && typeCode != StandardNames.XS_UNTYPED) { // if the element has simple content, whitespace stripping is disabled SchemaType type = getConfiguration().getSchemaType(typeCode); if (type.isSimpleType() || ((ComplexType)type).isSimpleContent()) { preserve |= CANNOT_STRIP; } } // put "preserve" value on top of stack top++; if (top >= stripStack.length) { byte[] newStack = new byte[top*2]; System.arraycopy(stripStack, 0, newStack, 0, top); stripStack = newStack; } stripStack[top] = preserve; }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException { if (parentType instanceof SimpleType || ((ComplexType) parentType).isSimpleContent()) { String msg = "Elements are not permitted here: the containing element "; if (parentType instanceof SimpleType) { if (parentType.isAnonymousType()) { msg += "is defined to have a simple type"; } else { msg += "is of simple type " + parentType.getDescription(); } } else { msg += "has a complex type with simple content"; } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } // NOTE: we could in principle check that if all the elements permitted in the content of the parentType // themselves have a simple type (not uncommon, perhaps) then this element must not have element content. }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException { if (parentType instanceof SimpleType) { XPathException err = new XPathException("Elements are not permitted here: the containing element has the simple type " + parentType.getDescription()); err.setIsTypeError(true); err.setLocator(this); throw err; } else if (((ComplexType)parentType).isSimpleContent()) { XPathException err = new XPathException("Elements are not permitted here: the containing element has a complex type with simple content"); err.setIsTypeError(true); err.setLocator(this); throw err; } // NOTE: we could in principle check that if all the elements permitted in the content of the parentType // themselves have a simple type (not uncommon, perhaps) then this element must not have element content. }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException { if (parentType instanceof SimpleType || ((ComplexType) parentType).isSimpleContent()) { String msg = "Elements are not permitted here: the containing element "; if (parentType instanceof SimpleType) { if (parentType.isAnonymousType()) { msg += "is defined to have a simple type"; } else { msg += "is of simple type " + parentType.getDescription(); } } else { msg += "has a complex type with simple content"; } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } // NOTE: we could in principle check that if all the elements permitted in the content of the parentType // themselves have a simple type (not uncommon, perhaps) then this element must not have element content. }
/** * Test whether a type annotation code represents the type xs:ID or one of its subtypes * @param typeCode the type annotation to be tested * @return true if the type annotation represents an xs:ID */ public boolean isIdCode(int typeCode) { typeCode &= NamePool.FP_MASK; if (typeCode == StandardNames.XS_ID) { return true; } else if (typeCode < 1024) { // No other built-in type is an ID return false; } else { SchemaType type = config.getSchemaType(typeCode); if (type == null) { return false; // this shouldn't happen, but there's no need to crash right here } if (type.isAtomicType()) { return isSubType((AtomicType)type, BuiltInAtomicType.ID); } if (type instanceof ComplexType && ((ComplexType)type).isSimpleContent()) { SimpleType contentType = ((ComplexType)type).getSimpleContentType(); if (contentType.isAtomicType()) { return isSubType((AtomicType)contentType, BuiltInAtomicType.ID); } } return false; } }
/** * Test whether a type annotation code represents the type xs:ID or one of its subtypes * @param typeCode the type annotation to be tested * @return true if the type annotation represents an xs:ID */ public boolean isIdCode(int typeCode) { typeCode &= NamePool.FP_MASK; if (typeCode == StandardNames.XS_ID) { return true; } else if (typeCode < 1024) { // No other built-in type is an ID return false; } else { SchemaType type = config.getSchemaType(typeCode); if (type == null) { return false; // this shouldn't happen, but there's no need to crash right here } if (type.isAtomicType()) { return isSubType((AtomicType)type, BuiltInAtomicType.ID); } if (type instanceof ComplexType && ((ComplexType)type).isSimpleContent()) { SimpleType contentType = ((ComplexType)type).getSimpleContentType(); if (contentType.isAtomicType()) { return isSubType((AtomicType)contentType, BuiltInAtomicType.ID); } } return false; } }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException { if (parentType instanceof SimpleType) { XPathException err = new XPathException("Elements are not permitted here: the containing element has the simple type " + parentType.getDescription()); err.setIsTypeError(true); err.setLocator(this); throw err; } else if (((ComplexType)parentType).isSimpleContent()) { XPathException err = new XPathException("Elements are not permitted here: the containing element has a complex type with simple content"); err.setIsTypeError(true); err.setLocator(this); throw err; } // NOTE: we could in principle check that if all the elements permitted in the content of the parentType // themselves have a simple type (not uncommon, perhaps) then this element must not have element content. }
return (AtomicType) mem; } else if (type instanceof ComplexType && ((ComplexType) type).isSimpleContent()) { SimpleType ctype = ((ComplexType) type).getSimpleContentType(); assert ctype != null;
return (AtomicType) mem; } else if (type instanceof ComplexType && ((ComplexType) type).isSimpleContent()) { SimpleType ctype = ((ComplexType) type).getSimpleContentType(); assert ctype != null;
/** * Get the item type of the atomic values that will be produced when an item * of this type is atomized (assuming that atomization succeeds) */ public AtomicType getAtomizedItemType() { SchemaType type = config.getSchemaType(requiredType); if (type.isAtomicType()) { return (AtomicType)type; } else if (type instanceof ListType) { SimpleType mem = ((ListType)type).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } else if (type instanceof ComplexType && ((ComplexType)type).isSimpleContent()) { SimpleType ctype = ((ComplexType)type).getSimpleContentType(); if (ctype.isAtomicType()) { return (AtomicType)ctype; } else if (ctype instanceof ListType) { SimpleType mem = ((ListType)ctype).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } } return BuiltInAtomicType.ANY_ATOMIC; }
/** * Get the item type of the atomic values that will be produced when an item * of this type is atomized (assuming that atomization succeeds) */ public AtomicType getAtomizedItemType() { SchemaType type = config.getSchemaType(requiredType); if (type.isAtomicType()) { return (AtomicType)type; } else if (type instanceof ListType) { SimpleType mem = ((ListType)type).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } else if (type instanceof ComplexType && ((ComplexType)type).isSimpleContent()) { SimpleType ctype = ((ComplexType)type).getSimpleContentType(); if (ctype.isAtomicType()) { return (AtomicType)ctype; } else if (ctype instanceof ListType) { SimpleType mem = ((ListType)ctype).getItemType(); if (mem.isAtomicType()) { return (AtomicType)mem; } } } return BuiltInAtomicType.ANY_ATOMIC; }
return ((ListType)type).getBuiltInBaseType().getFingerprint() == StandardNames.XS_IDREFS; if (type.isComplexType() && ((ComplexType)type).isSimpleContent()) { SimpleType contentType = ((ComplexType)type).getSimpleContentType(); if (contentType.isAtomicType()) {