public String toString() { return (kind == Type.ELEMENT ? "element(*, " : "attribute(*, ") + schemaType.getDescription() + ')'; }
public String toString() { return (kind == Type.ELEMENT ? "element(*, " : "attribute(*, ") + schemaType.getDescription() + ')'; }
private static String getStartingNodeDescription(SchemaType type) { String s = type.getDescription(); if (s.startsWith("of element")) { return "a valid element named" + s.substring("of element".length()); } else if (s.startsWith("of attribute")) { return "a valid attribute named" + s.substring("of attribute".length()); } else { return "a node with " + (type.isSimpleType() ? "simple" : "complex") + " type " + s; } }
private static String getStartingNodeDescription(SchemaType type) { String s = type.getDescription(); if (s.startsWith("of element")) { return "a valid element named" + s.substring("of element".length()); } else if (s.startsWith("of attribute")) { return "a valid attribute named" + s.substring("of attribute".length()); } else { return "a node with " + (type.isSimpleType() ? "simple" : "complex") + " type " + s; } }
/** * Check that this type is validly derived from a given type * * @param type the type from which this type is derived * @param block the derivations that are blocked by the relevant element declaration * @throws net.sf.saxon.type.SchemaException * if the derivation is not allowed */ public void checkTypeDerivationIsOK(/*@NotNull*/ SchemaType type, int block) throws SchemaException { if (type == this || type == AnySimpleType.getInstance()) { return; } throw new SchemaException("Type xs:error is not validly derived from " + type.getDescription()); }
/** * Check that this type is validly derived from a given type * * @param type the type from which this type is derived * @param block the derivations that are blocked by the relevant element declaration * @throws net.sf.saxon.type.SchemaException * if the derivation is not allowed */ public void checkTypeDerivationIsOK(/*@NotNull*/ SchemaType type, int block) throws SchemaException { if (type == this || type == AnySimpleType.getInstance()) { return; } throw new SchemaException("Type xs:error is not validly derived from " + type.getDescription()); }
/** * 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("Attributes are not permitted here: the containing element is of simple type " + parentType.getDescription()); err.setIsTypeError(true); err.setLocator(this); throw err; } }
/** * 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("Attributes are not permitted here: the containing element is of simple type " + parentType.getDescription()); err.setIsTypeError(true); err.setLocator(this); throw err; } }
/** * 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("Attributes are not permitted here: the containing element is of simple type " + parentType.getDescription()); err.setIsTypeError(true); err.setLocator(this); throw err; } }
/** * Check that this type is validly derived from a given type * * @param type the type from which this type is derived * @param block the derivations that are blocked by the relevant element declaration * @throws SchemaException if the derivation is not allowed */ public void checkTypeDerivationIsOK(SchemaType type, int block) throws SchemaException { if (type == AnySimpleType.getInstance()) { // OK } else if (isSameType(type)) { // OK } else { SchemaType base = getBaseType(); if (base == null) { throw new SchemaException("The type " + getDescription() + " is not validly derived from the type " + type.getDescription()); } try { base.checkTypeDerivationIsOK(type, block); } catch (SchemaException se) { throw new SchemaException("The type " + getDescription() + " is not validly derived from the type " + type.getDescription()); } } }
/** * 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) { String msg = "Attributes are not permitted here: "; if (parentType.isAnonymousType()) { msg += "the containing element is defined to have a simple type"; } else { msg += "the containing element is of simple type " + parentType.getDescription(); } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } }
/** * 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) { String msg = "Attributes are not permitted here: "; if (parentType.isAnonymousType()) { msg += "the containing element is defined to have a simple type"; } else { msg += "the containing element is of simple type " + parentType.getDescription(); } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } }
/** * 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. }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("documentNode"); out.emitAttribute("validation", Validation.toString(validation)); if (getSchemaType() != null) { out.emitAttribute("type", getSchemaType().getDescription()); } content.explain(out); out.endElement(); } }
/** * 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. }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("documentNode"); out.emitAttribute("validation", Validation.toString(validation)); if (getSchemaType() != null) { out.emitAttribute("type", getSchemaType().getDescription()); } content.explain(out); out.endElement(); } }
/** * 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. }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("directElement"); out.emitAttribute("name", out.getNamePool().getDisplayName(nameCode)); out.emitAttribute("validation", Validation.toString(validation)); if (getSchemaType() != null) { out.emitAttribute("type", getSchemaType().getDescription()); } content.explain(out); out.endElement(); } }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("directElement"); out.emitAttribute("name", out.getNamePool().getDisplayName(nameCode)); out.emitAttribute("validation", Validation.toString(validation)); if (getSchemaType() != null) { out.emitAttribute("type", getSchemaType().getDescription()); } content.explain(out); out.endElement(); } }
/** * Diagnostic print of expression structure. The abstract expression tree * is written to the supplied output destination. */ public void explain(ExpressionPresenter out) { out.startElement("computedElement"); out.emitAttribute("validation", Validation.toString(validation)); if (getSchemaType() != null) { out.emitAttribute("type", getSchemaType().getDescription()); } out.startSubsidiaryElement("name"); elementName.explain(out); out.endSubsidiaryElement(); if (namespace != null) { out.startSubsidiaryElement("namespace"); namespace.explain(out); out.endSubsidiaryElement(); } out.startSubsidiaryElement("content"); content.explain(out); out.endSubsidiaryElement(); out.endElement(); } }