Project

Profile

Help

Definition of schema-element SequenceType

Added by Andrea Desole about 9 years ago

I am in the process of implementing a function that has a parameter of type schema-element. I understand from the XPath specification that schema-element is a SequenceType, and as such I would expect to be able to pass the information about the parameter type in the form of a SequenceType object. That would fit the way ExtensionFunctionDefinition works. However, while I'm not expecting particular problems when the function is called (the schema-element is a regular element after all, so that's what I would expect to receive), I can't find a way to tell Saxon that my function takes a schema-element SequenceType. I am starting to think that I need to implement my own SequenceType to be used in the ExtensionFunctionDefinition, and treat the parameter as a regular node in the ExtensionFunctionCall. I was wondering if this is correct.


Replies (3)

Please register to reply

RE: Definition of schema-element SequenceType - Added by Michael Kay about 9 years ago

You can construct a SequenceType given an ItemType and a cardinality; some common ones are predefined as final static constants in the SequenceType class, but if the one you want isn't there, you can define it using SequenceType.makeSequenceType().

The ItemType you want is an instance of com.saxonica.validate.SchemaElementTest. To construct this, you will need the ElementDecl that represents the global element declaration in the schema. You can find this, given the element name, using Configuration.getElementDeclaration().

The cardinality of the SequenceType will be something like StaticProperty.ALLOWS_ONE_OR_MORE.

RE: Definition of schema-element SequenceType - Added by Andrea Desole about 9 years ago

Thanks. For the record, I found SchemaElementTest in com.saxonica.ee.validate, and it takes a com.saxonica.ee.schema.ElementDecl. I will assume it's safe to cast the SchemaDeclaration returned by Configuration.getElementDeclaration to an ElementDecl as long as the Configuration is an EnterpriseConfiguration. I won't be able to test this for a while, but that should do the job.

RE: Definition of schema-element SequenceType - Added by Michael Kay about 9 years ago

Yes, you should do the cast. I'm afraid it's a clumsiness caused by trying to keep the EE and HE products in line to the maximum extent possible.

    (1-3/3)

    Please register to reply