根據W3C函數返回類型問題
An ElementTest is used to match an element node by its name and/or type annotation. An ElementTest may take any of the following forms. In these forms, ElementName need not be present in the in-scope element declarations, but TypeName must be present in the in-scope schema types [err:XPST0008]. Note that substitution groups do not affect the semantics of ElementTest. ... element(*, TypeName) matches an element node regardless of its name, if derives-from(AT, TypeName) is true, where AT is the type annotation of the element node, and the nilled property of the node is false.
我有這個功能
import schema namespace cdm-base="http://cdm.basic.upc.com" at "file:///Workspace/peal/peal40/trunk/common/schema/cdm-basic.xsd";
declare function local:matchType(
$input as element()
) as element(*,cdm-base:ProductComponent..) {
<cdm-base:product xsi:type="cdm-base:ProductComponent" />
};
這同時我打字返回錯誤:
F [Saxon-EE XQuery 9.3.0.5] Required item type of result of function local:matchType() is element(*, ProductComponent); supplied value has item type element({http://cdm.basic.upc.com}product, {http://www.w3.org/2001/XMLSchema}untyped)
我可能錯了,但該類型實際上是cdm-base:ProductComponent而不是untyped。 我不明白其中的問題是...
我使用氧氣13.0撒克遜EE 9.3.0.5
看起來類型正在尋找甚至沒有,因爲錯誤提到{http://www.w3.org/2001/XMLSchema}untyped,雖然我有http://www.w3。 org/2001/XMLSchema-instance 但是那麼期待什麼屬性? declare namespace xsi =「http://www.w3.org/2001/XMLSchema-instance」; 聲明命名空間xs =「http://www.w3.org/2001/XMLSchema」; – AleIla 2012-01-06 10:12:07