PhoenixmlDb.XQuery

ISchemaProvider

Provides schema awareness to the XQuery and XSLT engines. Public extension point β€” callers can substitute their own implementation (RelaxNG, Schematron-derived, in-memory, dynamic) by passing it to the constructor.

#ISchemaProvider

Namespace: PhoenixmlDb.XQuery

Provides schema awareness to the XQuery and XSLT engines. Public extension point β€” callers can substitute their own implementation (RelaxNG, Schematron-derived, in-memory, dynamic) by passing it to the constructor.

The default implementation, , ships in this package and is registered automatically by . Together they provide the XQuery 3.1 "Schema-Aware Conformance" features: validate expressions (validate strict { ... }) schema-element() and schema-attribute() type tests import schema prolog declarations Typed node annotations (elements/attributes annotated with their XSD type) Full XSD type hierarchy for instance of and treat as Implement this interface to back schema processing with a non-XSD schema language, an in-memory schema, or a custom resolution strategy. The engine calls in at compile time (for static type checks) and at execution time (for validation and type annotation). Passing null for schemaProvider opts out of schema features entirely β€” every schema-element/attribute reference becomes XPST0008 and every validate raises XQDY0027. This is rare; intended for size-constrained embedded scenarios.

#Methods

#GetAttributeType(PhoenixmlDb.Xdm.XdmQName)

Returns the declared type name for a global attribute declaration.

Parameters:

  • name β€” The attribute QName.

Returns: The XSD type name, or null if the attribute is not declared.

#GetAttributeType(String,String)

String-URI overload of .

#GetElementType(PhoenixmlDb.Xdm.XdmQName)

Returns the declared type name for a global element declaration.

Parameters:

  • name β€” The element QName.

Returns: The XSD type name, or null if the element is not declared.

#GetElementType(String,String)

String-URI overload of .

#HasAttributeDeclaration(PhoenixmlDb.Xdm.XdmQName)

Checks whether a global attribute declaration exists in the in-scope schema definitions, corresponding to the schema-attribute(Name) type test.

Parameters:

  • name β€” The attribute QName to look up.

Returns: true if the attribute is declared in a loaded schema.

#HasAttributeDeclaration(String,String)

String-URI overload of .

#HasElementDeclaration(PhoenixmlDb.Xdm.XdmQName)

Checks whether a global element declaration exists in the in-scope schema definitions, corresponding to the schema-element(Name) type test.

Parameters:

  • name β€” The element QName to look up.

Returns: true if the element is declared in a loaded schema.

#HasElementDeclaration(String,String)

String-URI overload of . Preferred when the caller has the namespace URI directly (rather than going through a ), since is not always reversible to a URI.

#ImportSchema(String,Collections.Generic.IReadOnlyList<String>)

Imports a schema namespace, corresponding to the XQuery import schema declaration.

Parameters:

  • targetNamespace β€” The target namespace of the schema to import. An empty string represents the no-namespace schema.

  • locationHints β€” Optional location hints (URIs) for the schema document(s), from the at clause.

Exceptions:

  • SchemaException β€” Thrown if the schema cannot be loaded or contains errors (maps to XQST0059).

#IsSubtypeOf(PhoenixmlDb.Xdm.XdmTypeName,PhoenixmlDb.Xdm.XdmTypeName)

Determines whether is a subtype of in the XSD type derivation hierarchy.

Parameters:

  • actualType β€” The type to check.

  • requiredType β€” The type to check against.

Returns: true if is equal to or derived from .

This is the core type subsumption check used by instance of, treat as, and function argument coercion. The implementation must cover the full XSD 1.1 type hierarchy including built-in types, restriction, extension, union, and list derivation.

#MatchesSchemaAttribute(PhoenixmlDb.Xdm.Nodes.XdmAttribute,PhoenixmlDb.Xdm.XdmQName)

Checks whether an attribute matches a schema-attribute(Name) test. An attribute matches if it has the declared name and its type annotation is the declared type or a subtype.

Parameters:

  • attribute β€” The attribute node to test.

  • declarationName β€” The attribute declaration name from the schema-attribute() test.

Returns: true if the attribute matches the schema-attribute() test.

#MatchesSchemaAttribute(PhoenixmlDb.Xdm.Nodes.XdmAttribute,String,String)

String-URI overload of .

#MatchesSchemaElement(PhoenixmlDb.Xdm.Nodes.XdmElement,PhoenixmlDb.Xdm.XdmQName)

Checks whether an element matches a schema-element(Name) test. An element matches if it has the same name as the declaration (or a name in its substitution group) and its type annotation is the declared type or a subtype.

Parameters:

  • element β€” The element node to test.

  • declarationName β€” The element declaration name from the schema-element() test.

Returns: true if the element matches the schema-element() test.

#MatchesSchemaElement(PhoenixmlDb.Xdm.Nodes.XdmElement,String,String)

String-URI overload of .

#Validate(PhoenixmlDb.Xdm.Nodes.XdmNode,PhoenixmlDb.XQuery.ValidationMode,String,String)

Validates a node tree against the loaded schemas, corresponding to the validate expression.

Parameters:

  • node β€” The document or element node to validate.

  • mode β€” The validation mode (strict, lax, or type).

  • typeNamespaceUri β€” For , the namespace URI of the target type. Null for strict and lax modes.

  • typeLocalName β€” For , the local name of the target type. Null for strict and lax modes.

Returns: A validated copy of the node tree with type annotations applied.

Returns a deep copy of the input node tree with and populated from the schema. The original node tree is not modified. The validation mode determines behavior: β€” the element must have a global declaration. β€” validate if a declaration exists, pass through if not. β€” validate against a specific named type.

Exceptions:

  • SchemaValidationException β€” Thrown if validation fails (maps to XQDY0027 for strict/lax, XQDY0027 for type).

#ValidateAndAnnotate(String,PhoenixmlDb.XQuery.INodeBuilder,PhoenixmlDb.XQuery.ValidationMode,String,String)

Validates an XML string against the loaded schemas AND returns a freshly built XDM tree whose elements and attributes carry / populated from the schema.

Parameters:

  • xmlContent β€” The XML markup to validate and annotate.

  • builder β€” Node store / ID allocator the resulting tree is registered in.

  • mode β€” Validation mode (strict, lax, or type).

  • typeNamespaceUri β€” Optional namespace URI for type-mode validation.

  • typeLocalName β€” Optional local name for type-mode validation.

Returns: The annotated document node, or null if annotation is unsupported.

The new tree is registered in so it participates in the caller's node store and namespace interning. Returns null when the provider doesn't support an annotating parse β€” the caller should then fall back to the unannotated original node from the validate expression body. The default implementation returns null. Built-in providers (e.g. XsdSchemaProvider) override to drive a schema-validating XmlReader through XmlDocumentParser.Parse(reader, uri, schemas), which populates from SchemaInfo.SchemaType.

Exceptions:

  • SchemaValidationException β€” Thrown if validation fails (XQDY0027).

#ValidateXml(String,PhoenixmlDb.XQuery.ValidationMode,String,String)

Validates already-serialized XML content against the loaded schemas. Convenience overload for callers (notably xsl:result-document) that have a string in hand rather than an in-memory XDM tree. Throws (XQDY0027) on validation failure. Default implementation parses the content and delegates to the node-based via a minimal XdmNode adapter; implementations are encouraged to override with a more direct path.

#ValidateXmlFragment(String,PhoenixmlDb.XQuery.ValidationMode,String,String,Collections.Generic.IReadOnlyDictionary<String,String>)

Fragment-mode counterpart of . Validates an XML fragment (single element or sequence of nodes β€” not a complete document) against the loaded schemas. Used by XSLT for per-element / per-attribute / per-copy validation where no surrounding document declaration exists. Default falls back to .

Parameters:

  • xmlFragment β€” The XML fragment to validate.

  • mode β€” Validation mode.

  • typeNamespaceUri β€” Optional namespace URI for type-mode validation.

  • typeLocalName β€” Optional local name for type-mode validation.

  • inScopeNamespaces β€” Optional prefixβ†’URI bindings that should be visible to the fragment without being explicitly declared inside it. Required when the fragment uses prefixed names whose declarations live on an enclosing element that the caller cannot include in the fragment text.