/** * Make an ItemType representing an element declaration in the schema. This is the * equivalent of the XPath syntax <code>schema-element(element-name)</code> * * <p>It is undefined whether two calls supplying the same argument values will * return the same ItemType object.</p> * * @param name the element name * @return the ItemType * @throws SaxonApiException if the schema does not contain a global element declaration * for the given name */ public ItemType getSchemaElementTest(QName name) throws SaxonApiException { Configuration config = processor.getUnderlyingConfiguration(); int fingerprint = config.getNamePool().allocate("", name.getNamespaceURI(), name.getLocalName()); SchemaDeclaration decl = config.getElementDeclaration(fingerprint); if (decl == null) { throw new SaxonApiException("No global declaration found for element " + name.getClarkName()); } CombinedNodeTest combo = new CombinedNodeTest( new NameTest(Type.ELEMENT, fingerprint, config.getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ELEMENT, decl.getType(), config)); combo.setGlobalComponentTest(true); return new ItemType(combo, processor); }
/** * Get an ItemType representing an attribute declaration in the schema. This is the * equivalent of the XPath syntax <code>schema-attribute(attribute-name)</code> * * <p>It is undefined whether two calls supplying the same argument values will * return the same ItemType object.</p> * * @param name the attribute name * @return the ItemType * @throws SaxonApiException if the schema does not contain a global attribute declaration * for the given name */ public ItemType getSchemaAttributeTest(QName name) throws SaxonApiException { Configuration config = processor.getUnderlyingConfiguration(); int fingerprint = config.getNamePool().allocate("", name.getNamespaceURI(), name.getLocalName()); SchemaDeclaration decl = config.getAttributeDeclaration(fingerprint); if (decl == null) { throw new SaxonApiException("No global declaration found for attribute " + name.getClarkName()); } CombinedNodeTest combo = new CombinedNodeTest( new NameTest(Type.ATTRIBUTE, fingerprint, config.getNamePool()), Token.INTERSECT, new ContentTypeTest(Type.ATTRIBUTE, decl.getType(), config)); combo.setGlobalComponentTest(true); return new ItemType(combo, processor); }
} else { CombinedNodeTest combo = new CombinedNodeTest(nameTest, Token.INTERSECT, contentTest); combo.setGlobalComponentTest(schemaDeclaration); return combo;
} else { CombinedNodeTest combo = new CombinedNodeTest(nameTest, Token.INTERSECT, contentTest); combo.setGlobalComponentTest(schemaDeclaration); return combo;