Hello,
if I am not mistaken, the following code demonstrates a bug. The code extracts from a schema a type definition, referenced by an element declaration. The second line determines the element whose type definition is sought.
In mode 1, the type definition is not found, in mode 2 it is found. With Saxon, modes 1 and 2 are successful.
Strangely, at least with my XSD the error occurs only if the type to be found is xs:simpleType - it does not occur if it is xs:complexType.
Kind regards, Hans-Juergen
===================================
declare variable $schemas := /*; declare variable $elem := ($schemas//xs:element[@type eq 't:Room'])[1]; declare variable $mode := 1;
declare function local:getTypeDef($elem as element(xs:element)) as element()? { let $type := $elem/@type return
if (empty($type)) then $elem/(xs:simpleType, xs:complexType) else
let $qname := resolve-QName($type, $elem) let $lname := local-name-from-QName($qname) let $uri := namespace-uri-from-QName($qname) return if (empty($uri)) then let $actSchemas := $schemas[not(@targetNamespace)] return $actSchemas/(xs:complexType, xs:simpleType)[@name eq $lname] else if ($mode eq 1) then $schemas[@targetNamespace eq $uri]/(xs:complexType, xs:simpleType)[@name eq $lname] else let $actSchemas := $schemas[@targetNamespace eq $uri] let $types := $actSchemas/(xs:complexType, xs:simpleType) return $types[@name eq $lname] };
<typeDef>{ local:getTypeDef($elem) }</typeDef> ==============================================
Hi Hans-Jürgen,
do you have an example document to get the query running?
Thanks in advance, Christian ___________________________
if I am not mistaken, the following code demonstrates a bug. The code extracts from a schema a type definition, referenced by an element declaration. The second line determines the element whose type definition is sought.
In mode 1, the type definition is not found, in mode 2 it is found. With Saxon, modes 1 and 2 are successful.
Strangely, at least with my XSD the error occurs only if the type to be found is xs:simpleType - it does not occur if it is xs:complexType.
Kind regards, Hans-Juergen
===================================
declare variable $schemas := /*; declare variable $elem := ($schemas//xs:element[@type eq 't:Room'])[1]; declare variable $mode := 1;
declare function local:getTypeDef($elem as element(xs:element)) as element()? { let $type := $elem/@type return
if (empty($type)) then $elem/(xs:simpleType, xs:complexType) else
let $qname := resolve-QName($type, $elem) let $lname := local-name-from-QName($qname) let $uri := namespace-uri-from-QName($qname) return if (empty($uri)) then let $actSchemas := $schemas[not(@targetNamespace)] return $actSchemas/(xs:complexType, xs:simpleType)[@name eq $lname] else if ($mode eq 1) then $schemas[@targetNamespace eq $uri]/(xs:complexType, xs:simpleType)[@name eq $lname] else let $actSchemas := $schemas[@targetNamespace eq $uri] let $types := $actSchemas/(xs:complexType, xs:simpleType) return $types[@name eq $lname] };
<typeDef>{ local:getTypeDef($elem) }</typeDef>
==============================================
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
..fixed [1]! As usual, new snapshots are available [2]. Christian
[1] https://github.com/BaseXdb/basex/issues/567 [2] http://files.basex.org/releases/latest/ ___________________________
On Thu, Aug 30, 2012 at 2:46 PM, Hans-Juergen Rennau hrennau@yahoo.de wrote:
Hello,
if I am not mistaken, the following code demonstrates a bug. The code extracts from a schema a type definition, referenced by an element declaration. The second line determines the element whose type definition is sought.
In mode 1, the type definition is not found, in mode 2 it is found. With Saxon, modes 1 and 2 are successful.
Strangely, at least with my XSD the error occurs only if the type to be found is xs:simpleType - it does not occur if it is xs:complexType.
Kind regards, Hans-Juergen
===================================
declare variable $schemas := /*; declare variable $elem := ($schemas//xs:element[@type eq 't:Room'])[1]; declare variable $mode := 1;
declare function local:getTypeDef($elem as element(xs:element)) as element()? { let $type := $elem/@type return
if (empty($type)) then $elem/(xs:simpleType, xs:complexType) else
let $qname := resolve-QName($type, $elem) let $lname := local-name-from-QName($qname) let $uri := namespace-uri-from-QName($qname) return if (empty($uri)) then let $actSchemas := $schemas[not(@targetNamespace)] return $actSchemas/(xs:complexType, xs:simpleType)[@name eq $lname] else if ($mode eq 1) then $schemas[@targetNamespace eq $uri]/(xs:complexType, xs:simpleType)[@name eq $lname] else let $actSchemas := $schemas[@targetNamespace eq $uri] let $types := $actSchemas/(xs:complexType, xs:simpleType) return $types[@name eq $lname] };
<typeDef>{ local:getTypeDef($elem) }</typeDef>
==============================================
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de