inexplicable query parsing issue; "could not execute XQUERY..."
Tuesday, 7 May 2013 · 3 messages · last reply 8 May 2013
CG
Hi Graydon,
thanks for the report; we can reproduce the problem and give you notice as soon as it’s fixed. Feel free to follow the issue at GitHub [1].
Best,
Christian
[1] https://github.com/BaseXdb/basex/issues/696
Quoted text · Graydon Saunders · 403 lines
On Tue, May 7, 2013 at 5:34 PM, Graydon Saunders <graydonish at gmail.com> wrote: > Running BaseX77-20130503.190321 > > The horrible query works until I add the second ("local:addArea") function > to it; that works fine in its own smaller query, which I've attached. (as > far as I can tell, it really is the function causing the problem.) > > I've attached the horrible query as well, just in case it's not all in the > error message. > > The GUI is showing me "OK" in the bottom left corner. > > Contents of error popup: > > Could not execute XQUERY declare function local:addArea($area as > xs:string,$uri as xs:string,$path as xs:string,$element as element()) { > > element {node-name($element)} > { > $element/@*, > attribute {'area'} {$area}, > attribute {'uri'} {$uri}, > attribute {'path'} {$path}, > $element/node() > } > }; > > declare function local:reportError($type as xs:string,$file as > xs:anyURI,$match as item(),$addInfo as item()*) > as element(error) { > > let $errorMsg := > <messages> > <msg><type>BASE0000</type><words>Document loaded into collection is not a > WKNA-Shared-CMS.dtd document; document element is not > wkna-shared-cms</words></msg> > <msg><type>CITE0000</type><words>Cite attribute values are required to > contain non-whitespace characters</words></msg> > <msg><type>CITE0005</type><words>Cite attribute value contains characters > not permitted in cite attribute values</words></msg> > <msg><type>CITE0010</type><words>num element must have at least one of an > associated cite attribute with a non-whitespace string value or > non-whitespace string-contents</words></msg> > <msg><type>CITE0020</type><words>num element with associated type attribute > with value "heading" has been deprecated and is not permitted</words></msg> > <msg><type>CITE0030</type><words>duplicate locative citations</words></msg> > <msg><type>FILE0010</type><words>document-defining element area-cite pair > does not match basename component of pathname</words></msg> > <msg><type>DATE0010</type><words>date element has no associated status > attribute or status attribute value</words></msg> > <msg><type>DATE0020</type><words>date element has an associated date > attribute with a null value</words></msg> > <msg><type>DATE0030</type><words>date element has an associated date > attribute with a value outside the permissible date range</words></msg> > <msg><type>DATE0040</type><words>date element has an associated status > attribute value not on the permitted list of status values</words></msg> > <msg><type>DATE0050</type><words>date element has no associated date > attribute while having a status value which does not permit the date > attribute to be absent</words></msg> > <msg><type>AREA0000</type><words>area attribute with no value</words></msg> > <msg><type>AREA0001</type><words>area attribute value does not conform to > NCName type restrictions</words></msg> > <msg><type>AREA0010</type><words>area attribute associated with an assembly > element has a value which is not a defined area</words></msg> > <msg><type>AREA0020</type><words>area attribute associated with a > horizon-level element has a value which is not a defined area</words></msg> > <msg><type>AREA0030</type><words>area attribute NOT associated with a > horizon-level element</words></msg> > <msg><type>AREA0040</type><words>area attribute NOT associated with a > feature horizon-level element</words></msg> > <msg><type>AREA0045</type><words>area attribute associated with a feature > horizon-level element has a value which is not a defined area</words></msg> > <msg><type>AREA0050</type><words>area attribute associated with an include > element has a value which is not a defined area</words></msg> > <msg><type>AREA0051</type><words>include element with special-case > associated area attribute value "fragments" has an associated cite attribute > with a value OTHER THAN "empty" or "omitted" which is not > permitted</words></msg> > <msg><type>AREA0060</type><words>area attribute associated with a source > element has a value which is not a defined area</words></msg> > <msg><type>AREA0070</type><words>area attribute associated with a > related-content-ref element has a value which is not a defined > area</words></msg> > <msg><type>AREA0080</type><words>area attribute associated with a link-type > element has a value which is not a defined area</words></msg> > <msg><type>REFR0010</type><words>include elements must reference an existing > locative citation</words></msg> > <msg><type>REFR0020</type><words>source elements must reference a locative > citation (area-cite pair) which exists in the same document</words></msg> > <msg><type>REFR0030</type><words>related-content-ref elements must reference > a locative citation (area-cite pair) which exists in the same > document</words></msg> > <msg><type>LINK0010</type><words>link elements must have a non-whitespace > string value</words></msg> > </messages> > > return > > > <error type="{xs:NCName($type)}"> > <uri>{$file}</uri> > <description>{string($errorMsg/msg[type eq $type]/words)} > {if (normalize-space($addInfo) or $addInfo instance of node()) then $addInfo > else ()}</description> > <path>{replace(path($match),'/Q\{[^\}]*\}','/')}</path> > {if ($match[self::element() and (self::assembly or self::va-object or > self::provision or self::agency-doc or self::commentary or self::decision or > self::fragment or self::index)]) > then element {name($match)} {$match/@area} > else $match} > </error> > }; > > (: definitions for cite and cite-related checks:) > > let $citeChars := > 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.(),'/[]%:|⦅ÀÂÇÉÈÊËÎÏÔÛÙÜŸÑàâçéèêëîïôûùüÿñœ ' > > (: definitions for date checks :) > let $dateStart := xs:date('1900-01-01') > let $dateEnd := current-date() + xs:yearMonthDuration('P5Y0M') > let $statusList := ('active', 'amended', 'archived', 'cancelled', > 'consolidated', 'effective', 'first-reading', 'former', 'heard', 'oral', > 'published', 'released', 'repealed', 'replaced', 'resolved', 'reviewed', > 'revised', 'revoked', 'royal-assent', 'written') > let $absentDateStatus := > ('amended','archived','former','repealed','revoked') > > (: definitions for area checks :) > let $areasList := > doc(concat('file:',string-join(tokenize(substring-after(static-base-uri(),':'),'/')[not(position() > = (last(),last() > -1))],'/'),'/XSLT/DTDs/areas-metadata.xml'))/wkna-shared-cms/area/@area > > (: definitions for reference checks :) > let $locativeNums := for $x in collection()//num[ancestor::*[@area][@area > castable as > xs:NCName]][@cite][matches(@cite,'\P{Zs}')][translate(@cite,$citeChars,'') > eq ''] > return local:addArea($x/ancestor::*[@area][@area castable as > xs:NCName][1]/@area/string(),base-uri($x),replace(path($x),'/Q\{[^\}]*\}','/'),$x) > > let $sortedNums := for $x in $locativeNums order by $x/@area,$x/@cite return > $x > > (: perform actual checks:) > return file:write('/home/graydon/checks.xml', > <bucket> > { > for tumbling window $w in $sortedNums > start $s previous $pitem when concat($s/@area,'|',$s/@cite) ne > concat($pitem/@area,'|',$pitem/@cite) > return if ($w[2]) then local:reportError('CITE0030','',$w,'') else () > } > { > for $file in collection() > let $path := document-uri($file) > > return > if (not($file/wkna-shared-cms)) > then local:reportError('BASE0000',$path,'','') > > else > let $bad := ( > (:check area + primary cite matches file name :) > for $x in $file/wkna-shared-cms/*[self::assembly or self::provision or > self::decision or self::agency-doc or self::commentary or self::fragment or > self::index][1] > return > if > ($x!concat(@area,'+',replace(replace(translate(translate(num[@cite][1]/@cite,'ÀÂÇÉÈÊËÎÏÔÛÙÜŸÑàâçéèêëîïôûùüÿñ','AACEEEEIIOUUUYNaaceeeeiiouuuyn'),' > /[]%:','______'),'_+','_'),'^_+|_+$',''),'.xml') eq > tokenize($path,'/')[last()]) > then () > else local:reportError('FILE0010',$path,$x,$x/num[@cite][1]), > > (: checks on cite values :) > for $x in $file//@cite[not(matches(.,'\P{Zs}'))] return > local:reportError('CITE0000',$path,$x/..,''), > for $x in $file//@cite[matches(.,'\P{Zs}')][translate(.,$citeChars,'') ne > ''] return local:reportError('CITE0005',$path,$x/..,concat(' The characters > ',translate($x,$citeChars,''),' are not permitted in cite attribute > values.')), > > (: checks on num elements:) > for $x in $file//num[not(normalize-space(@cite) or matches(.,'\P{Zs}'))] > return local:reportError('CITE0010',$path,$x,''), > for $x in $file//num[@type eq 'heading'] return > local:reportError('CITE0020',$path,$x,''), > > (: checks on date elements :) > for $x in $file//date[not(@status) or not(normalize-space(@status))] return > local:reportError('DATE0010',$path,$x,''), > for $x in $file//date[@date][not(normalize-space(@date))] return > local:reportError('DATE0020',$path,$x,''), > for $x in $file//date[@date castable as xs:date or @date castable as > xs:gYear or @date castable as xs:gYearMonth] > let $compare := if ($x/@date castable as xs:date) then xs:date($x/@date) > else if ($x/@date castable as xs:gYearMonth) then > xs:date(concat(xs:string(xs:gYearMonth($x/@date)),'-01')) > else xs:date(concat(xs:string(xs:gYear($x/@date)),'-01-01')) > > return if ($compare lt $dateStart or $compare gt $dateEnd) then > local:reportError('DATE0030',$path,$x,concat('Permissible dates lie betwee > ',$dateStart,' and ',$dateEnd,' inclusive.')) else (), > > for $x in $file//date[@status][normalize-space(@status)][not(@status = > $statusList)] return local:reportError('DATE0040',$path,$x,''), > for $x in $file//date[@status][normalize-space(@status)][@status = > $statusList][not(@status = $absentDateStatus)][not(@date)] return > local:reportError('DATE0050',$path,$x,''), > > (: checks on link elements :) > for $x in $file//link[not(matches(.,'\P{Zs}'))] return > local:reportError('LINK0010',$path,$x,''), > > (: checks on area attributes:) > for $x in $file//@area[not(normalize-space())] return > local:reportError('AREA0000',$path,$x/..,''), > for $x in $file//@area[not(. castable as xs:NCName)] return > local:reportError('AREA0001',$path,$x/..,''), > for $x in $file//assembly[@area][normalize-space(@area)][@area castable as > xs:NCName]/@area[not(. = $areasList)] return > local:reportError('AREA0010',$path,$x/..,''), > for $x in $file//*[self::provision or self::commentary or self::decision or > self::agency-doc or self::fragment][@area][normalize-space(@area)][@area > castable as xs:NCName][@area[not(. = $areasList)]] > return local:reportError('AREA0020',$path,$x,''), > for $x in $file//*[self::provision or self::commentary or self::decision or > self::agency-doc][not(@area) or not(normalize-space(@area))] return > local:reportError('AREA0030',$path,$x,''), > for $x in $file//*[self::va-object][not(@area) or > not(normalize-space(@area))] return > local:reportError('AREA0040',$path,$x,''), > for $x in $file//*[self::va-object][@area][normalize-space(@area)][@area > castable as xs:NCName][not(@area = $areasList)] return > local:reportError('AREA0045',$path,$x,''), > for $x in $file//include[@area][normalize-space(@area)][@area castable as > xs:NCName][not(@area = $areasList)] return > local:reportError('AREA0050',$path,$x,''), > for $x in $file//include[@area][normalize-space(@area)][@area castable as > xs:NCName][@area = 'fragments'][not(@cite = ('empty','omitted'))] return > local:reportError('AREA0051',$path,$x,''), > for $x in $file//source[@area][normalize-space(@area)][@area castable as > xs:NCName][not(@area = $areasList)] return > local:reportError('AREA0060',$path,$x,''), > for $x in $file//related-content-ref[@area][normalize-space(@area)][@area > castable as xs:NCName][not(@area = $areasList)] return > local:reportError('AREA0070',$path,$x,''), > for $x in $file//*[@area][normalize-space(@area)][@area castable as > xs:NCName][self::link or self::target][not(@area = $areasList)] return > local:reportError('AREA0080',$path,$x,''), > > (:check references:) > for $x in > $file//include[not(map:contains($allLocations,concat(@area,'|',@cite)))] > return local:reportError('REFR0010',$path,$x,''), > for $x in $file//source[not(some $num in $file//num satisfies $num/@cite eq > @cite and $num/ancestor::*[@area][1]/@area eq @area)] return > local:reportError('REFR0020',$path,$x,''), > for $x in $file//related-content-ref[not(some $num in $file//num satisfies > $num/@cite eq @cite and $num/ancestor::*[@area][1]/@area eq @area)] return > local:reportError('REFR0030',$path,$x,'') > > ) > > return if ($bad/*) then $bad else () > }</bucket>): > Improper use? Potential bug? Your feedback is welcome: > Contact: basex-talk at mailman.uni-konstanz.de > Version: BaseX 7.7 beta > Java: Oracle Corporation, 1.7.0_09 > OS: Linux, amd64 > Stack Trace: > java.lang.NullPointerException > org.basex.query.var.StaticVarRef.uses(StaticVarRef.java:61) > org.basex.query.expr.Arr.uses(Arr.java:45) > org.basex.query.func.FNMap.uses(FNMap.java:137) > org.basex.query.expr.Arr.uses(Arr.java:45) > org.basex.query.path.Step.get(Step.java:55) > org.basex.query.QueryParser.axisStep(QueryParser.java:1950) > org.basex.query.QueryParser.step(QueryParser.java:1896) > org.basex.query.QueryParser.relativePath(QueryParser.java:1845) > org.basex.query.QueryParser.path(QueryParser.java:1819) > org.basex.query.QueryParser.value(QueryParser.java:1699) > org.basex.query.QueryParser.unary(QueryParser.java:1686) > org.basex.query.QueryParser.cast(QueryParser.java:1664) > org.basex.query.QueryParser.castable(QueryParser.java:1652) > org.basex.query.QueryParser.treat(QueryParser.java:1640) > org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) > org.basex.query.QueryParser.intersect(QueryParser.java:1607) > org.basex.query.QueryParser.union(QueryParser.java:1581) > org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) > org.basex.query.QueryParser.additive(QueryParser.java:1550) > org.basex.query.QueryParser.range(QueryParser.java:1539) > org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) > org.basex.query.QueryParser.ftContains(QueryParser.java:1499) > org.basex.query.QueryParser.comparison(QueryParser.java:1481) > org.basex.query.QueryParser.and(QueryParser.java:1467) > org.basex.query.QueryParser.or(QueryParser.java:1453) > org.basex.query.QueryParser.single(QueryParser.java:1032) > org.basex.query.QueryParser.forClause(QueryParser.java:1179) > org.basex.query.QueryParser.initialClause(QueryParser.java:1149) > org.basex.query.QueryParser.flwor(QueryParser.java:1048) > org.basex.query.QueryParser.single(QueryParser.java:1021) > org.basex.query.QueryParser.expr(QueryParser.java:1010) > org.basex.query.QueryParser.parenthesized(QueryParser.java:2291) > org.basex.query.QueryParser.primary(QueryParser.java:2054) > org.basex.query.QueryParser.postfix(QueryParser.java:2014) > org.basex.query.QueryParser.step(QueryParser.java:1895) > org.basex.query.QueryParser.path(QueryParser.java:1811) > org.basex.query.QueryParser.value(QueryParser.java:1699) > org.basex.query.QueryParser.unary(QueryParser.java:1686) > org.basex.query.QueryParser.cast(QueryParser.java:1664) > org.basex.query.QueryParser.castable(QueryParser.java:1652) > org.basex.query.QueryParser.treat(QueryParser.java:1640) > org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) > org.basex.query.QueryParser.intersect(QueryParser.java:1607) > org.basex.query.QueryParser.union(QueryParser.java:1581) > org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) > org.basex.query.QueryParser.additive(QueryParser.java:1550) > org.basex.query.QueryParser.range(QueryParser.java:1539) > org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) > org.basex.query.QueryParser.ftContains(QueryParser.java:1499) > org.basex.query.QueryParser.comparison(QueryParser.java:1481) > org.basex.query.QueryParser.and(QueryParser.java:1467) > org.basex.query.QueryParser.or(QueryParser.java:1453) > org.basex.query.QueryParser.single(QueryParser.java:1032) > org.basex.query.QueryParser.letClause(QueryParser.java:1205) > org.basex.query.QueryParser.initialClause(QueryParser.java:1148) > org.basex.query.QueryParser.flwor(QueryParser.java:1048) > org.basex.query.QueryParser.single(QueryParser.java:1021) > org.basex.query.QueryParser.iff(QueryParser.java:1443) > org.basex.query.QueryParser.single(QueryParser.java:1025) > org.basex.query.QueryParser.flwor(QueryParser.java:1130) > org.basex.query.QueryParser.single(QueryParser.java:1021) > org.basex.query.QueryParser.expr(QueryParser.java:1001) > org.basex.query.QueryParser.enclosed(QueryParser.java:990) > org.basex.query.QueryParser.dirElemContent(QueryParser.java:2541) > org.basex.query.QueryParser.dirElement(QueryParser.java:2487) > org.basex.query.QueryParser.constructor(QueryParser.java:2371) > org.basex.query.QueryParser.primary(QueryParser.java:2056) > org.basex.query.QueryParser.postfix(QueryParser.java:2014) > org.basex.query.QueryParser.step(QueryParser.java:1895) > org.basex.query.QueryParser.path(QueryParser.java:1811) > org.basex.query.QueryParser.value(QueryParser.java:1699) > org.basex.query.QueryParser.unary(QueryParser.java:1686) > org.basex.query.QueryParser.cast(QueryParser.java:1664) > org.basex.query.QueryParser.castable(QueryParser.java:1652) > org.basex.query.QueryParser.treat(QueryParser.java:1640) > org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) > org.basex.query.QueryParser.intersect(QueryParser.java:1607) > org.basex.query.QueryParser.union(QueryParser.java:1581) > org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) > org.basex.query.QueryParser.additive(QueryParser.java:1550) > org.basex.query.QueryParser.range(QueryParser.java:1539) > org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) > org.basex.query.QueryParser.ftContains(QueryParser.java:1499) > org.basex.query.QueryParser.comparison(QueryParser.java:1481) > org.basex.query.QueryParser.and(QueryParser.java:1467) > org.basex.query.QueryParser.or(QueryParser.java:1453) > org.basex.query.QueryParser.single(QueryParser.java:1032) > org.basex.query.QueryParser.argumentList(QueryParser.java:2352) > org.basex.query.QueryParser.functionCall(QueryParser.java:2308) > org.basex.query.QueryParser.primary(QueryParser.java:2063) > org.basex.query.QueryParser.postfix(QueryParser.java:2014) > org.basex.query.QueryParser.step(QueryParser.java:1895) > org.basex.query.QueryParser.path(QueryParser.java:1811) > org.basex.query.QueryParser.value(QueryParser.java:1699) > org.basex.query.QueryParser.unary(QueryParser.java:1686) > org.basex.query.QueryParser.cast(QueryParser.java:1664) > org.basex.query.QueryParser.castable(QueryParser.java:1652) > org.basex.query.QueryParser.treat(QueryParser.java:1640) > org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) > org.basex.query.QueryParser.intersect(QueryParser.java:1607) > org.basex.query.QueryParser.union(QueryParser.java:1581) > org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) > org.basex.query.QueryParser.additive(QueryParser.java:1550) > org.basex.query.QueryParser.range(QueryParser.java:1539) > org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) > org.basex.query.QueryParser.ftContains(QueryParser.java:1499) > org.basex.query.QueryParser.comparison(QueryParser.java:1481) > org.basex.query.QueryParser.and(QueryParser.java:1467) > org.basex.query.QueryParser.or(QueryParser.java:1453) > org.basex.query.QueryParser.single(QueryParser.java:1032) > org.basex.query.QueryParser.flwor(QueryParser.java:1130) > org.basex.query.QueryParser.single(QueryParser.java:1021) > org.basex.query.QueryParser.expr(QueryParser.java:1001) > org.basex.query.QueryParser.parseMain(QueryParser.java:176) > org.basex.query.QueryContext.parse(QueryContext.java:176) > org.basex.query.QueryProcessor.parse(QueryProcessor.java:53) > org.basex.core.cmd.AQuery.updating(AQuery.java:137) > org.basex.core.cmd.AQuery.updating(AQuery.java:223) > org.basex.gui.GUI.exec(GUI.java:384) > org.basex.gui.GUI$7.run(GUI.java:349) > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
GS
Graydon Saunders7 May 2013 19:34 #
Running BaseX77-20130503.190321
The horrible query works until I add the second ("local:addArea") function to it; that works fine in its own smaller query, which I've attached. (as far as I can tell, it really is the function causing the problem.)
I've attached the horrible query as well, just in case it's not all in the error message.
The GUI is showing me "OK" in the bottom left corner.
Contents of error popup:
Could not execute XQUERY declare function local:addArea($area as
xs:string,$uri as xs:string,$path as xs:string,$element as element()) {
element {node-name($element)}
{
$element/@*,
attribute {'area'} {$area},
attribute {'uri'} {$uri},
attribute {'path'} {$path},
$element/node()
}
};
declare function local:reportError($type as xs:string,$file as
xs:anyURI,$match as item(),$addInfo as item()*)
as element(error) {
let $errorMsg :=
<messages>
<msg><type>BASE0000</type><words>Document loaded into collection is not a
WKNA-Shared-CMS.dtd document; document element is not
wkna-shared-cms</words></msg>
<msg><type>CITE0000</type><words>Cite attribute values are required to
contain non-whitespace characters</words></msg>
<msg><type>CITE0005</type><words>Cite attribute value contains characters
not permitted in cite attribute values</words></msg>
<msg><type>CITE0010</type><words>num element must have at least one of an
associated cite attribute with a non-whitespace string value or
non-whitespace string-contents</words></msg>
<msg><type>CITE0020</type><words>num element with associated type attribute
with value "heading" has been deprecated and is not permitted</words></msg>
<msg><type>CITE0030</type><words>duplicate locative citations</words></msg>
<msg><type>FILE0010</type><words>document-defining element area-cite pair
does not match basename component of pathname</words></msg>
<msg><type>DATE0010</type><words>date element has no associated status
attribute or status attribute value</words></msg>
<msg><type>DATE0020</type><words>date element has an associated date
attribute with a null value</words></msg>
<msg><type>DATE0030</type><words>date element has an associated date
attribute with a value outside the permissible date range</words></msg>
<msg><type>DATE0040</type><words>date element has an associated status
attribute value not on the permitted list of status values</words></msg>
<msg><type>DATE0050</type><words>date element has no associated date
attribute while having a status value which does not permit the date
attribute to be absent</words></msg>
<msg><type>AREA0000</type><words>area attribute with no value</words></msg>
<msg><type>AREA0001</type><words>area attribute value does not conform to
NCName type restrictions</words></msg>
<msg><type>AREA0010</type><words>area attribute associated with an assembly
element has a value which is not a defined area</words></msg>
<msg><type>AREA0020</type><words>area attribute associated with a
horizon-level element has a value which is not a defined area</words></msg>
<msg><type>AREA0030</type><words>area attribute NOT associated with a
horizon-level element</words></msg>
<msg><type>AREA0040</type><words>area attribute NOT associated with a
feature horizon-level element</words></msg>
<msg><type>AREA0045</type><words>area attribute associated with a feature
horizon-level element has a value which is not a defined area</words></msg>
<msg><type>AREA0050</type><words>area attribute associated with an include
element has a value which is not a defined area</words></msg>
<msg><type>AREA0051</type><words>include element with special-case
associated area attribute value "fragments" has an associated cite
attribute with a value OTHER THAN "empty" or "omitted" which is not
permitted</words></msg>
<msg><type>AREA0060</type><words>area attribute associated with a source
element has a value which is not a defined area</words></msg>
<msg><type>AREA0070</type><words>area attribute associated with a
related-content-ref element has a value which is not a defined
area</words></msg>
<msg><type>AREA0080</type><words>area attribute associated with a link-type
element has a value which is not a defined area</words></msg>
<msg><type>REFR0010</type><words>include elements must reference an
existing locative citation</words></msg>
<msg><type>REFR0020</type><words>source elements must reference a locative
citation (area-cite pair) which exists in the same document</words></msg>
<msg><type>REFR0030</type><words>related-content-ref elements must
reference a locative citation (area-cite pair) which exists in the same
document</words></msg>
<msg><type>LINK0010</type><words>link elements must have a non-whitespace
string value</words></msg>
</messages>return
<error type="{xs:NCName($type)}">
<uri>{$file}</uri>
<description>{string($errorMsg/msg[type eq $type]/words)}
{if (normalize-space($addInfo) or $addInfo instance of node()) then
$addInfo else ()}</description>
<path>{replace(path($match),'/Q\{[^\}]*\}','/')}</path>
{if ($match[self::element() and (self::assembly or self::va-object or
self::provision or self::agency-doc or self::commentary or self::decision
or self::fragment or self::index)])
then element {name($match)} {$match/@area}
else $match}
</error>
};(: definitions for cite and cite-related checks:)
let $citeChars :=
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.(),'/[]%:|⦅ÀÂÇÉÈÊËÎÏÔÛÙÜŸÑàâçéèêëîïôûùüÿñœ '
(: definitions for date checks :)
let $dateStart := xs:date('1900-01-01')
let $dateEnd := current-date() + xs:yearMonthDuration('P5Y0M') let $statusList := ('active', 'amended', 'archived', 'cancelled', 'consolidated', 'effective', 'first-reading', 'former', 'heard', 'oral', 'published', 'released', 'repealed', 'replaced', 'resolved', 'reviewed', 'revised', 'revoked', 'royal-assent', 'written')
let $absentDateStatus :=
('amended','archived','former','repealed','revoked')
(: definitions for area checks :)
let $areasList :=
doc(concat('file:',string-join(tokenize(substring-after(static-base-uri(),':'),'/')[not(position() = (last(),last()
-1))],'/'),'/XSLT/DTDs/areas-metadata.xml'))/wkna-shared-cms/area/@area
(: definitions for reference checks :)
let $locativeNums := for $x in collection()//num[ancestor::*[@area][@area
castable as
xs:NCName]][@cite][matches(@cite,'\P{Zs}')][translate(@cite,$citeChars,'')
eq '']
return local:addArea($x/ancestor::*[@area][@area castable as
xs:NCName][1]/@area/string(),base-uri($x),replace(path($x),'/Q\{[^\}]*\}','/'),$x)
let $sortedNums := for $x in $locativeNums order by $x/@area,$x/@cite
return $x
(: perform actual checks:)
return file:write('/home/graydon/checks.xml',
<bucket>
{
for tumbling window $w in $sortedNums
start $s previous $pitem when concat($s/@area,'|',$s/@cite) ne
concat($pitem/@area,'|',$pitem/@cite)
return if ($w[2]) then local:reportError('CITE0030','',$w,'') else ()
}
{
for $file in collection()
let $path := document-uri($file)
return
if (not($file/wkna-shared-cms))
then local:reportError('BASE0000',$path,'','')
else
let $bad := (
(:check area + primary cite matches file name :)
for $x in $file/wkna-shared-cms/*[self::assembly or self::provision or
self::decision or self::agency-doc or self::commentary or self::fragment or
self::index][1]
return
if
($x!concat(@area,'+',replace(replace(translate(translate(num[@cite][1]/@cite,'ÀÂÇÉÈÊËÎÏÔÛÙÜŸÑàâçéèêëîïôûùüÿñ','AACEEEEIIOUUUYNaaceeeeiiouuuyn'),'
/[]%:','______'),'_+','_'),'^_+|_+$',''),'.xml') eq
tokenize($path,'/')[last()])
then ()
else local:reportError('FILE0010',$path,$x,$x/num[@cite][1]),
(: checks on cite values :)
for $x in $file//@cite[not(matches(.,'\P{Zs}'))] return
local:reportError('CITE0000',$path,$x/..,''),
for $x in $file//@cite[matches(.,'\P{Zs}')][translate(.,$citeChars,'') ne
''] return local:reportError('CITE0005',$path,$x/..,concat(' The characters
',translate($x,$citeChars,''),' are not permitted in cite attribute
values.')),
(: checks on num elements:)
for $x in $file//num[not(normalize-space(@cite) or matches(.,'\P{Zs}'))]
return local:reportError('CITE0010',$path,$x,''),
for $x in $file//num[@type eq 'heading'] return
local:reportError('CITE0020',$path,$x,''),
(: checks on date elements :)
for $x in $file//date[not(@status) or not(normalize-space(@status))] return
local:reportError('DATE0010',$path,$x,''),
for $x in $file//date[@date][not(normalize-space(@date))] return
local:reportError('DATE0020',$path,$x,''),
for $x in $file//date[@date castable as xs:date or @date castable as
xs:gYear or @date castable as xs:gYearMonth]
let $compare := if ($x/@date castable as xs:date) then xs:date($x/@date)
else if ($x/@date castable as xs:gYearMonth) then
xs:date(concat(xs:string(xs:gYearMonth($x/@date)),'-01'))
else xs:date(concat(xs:string(xs:gYear($x/@date)),'-01-01'))
return if ($compare lt $dateStart or $compare gt $dateEnd) then
local:reportError('DATE0030',$path,$x,concat('Permissible dates lie betwee
',$dateStart,' and ',$dateEnd,' inclusive.')) else (),
for $x in $file//date[@status][normalize-space(@status)][not(@status =
$statusList)] return local:reportError('DATE0040',$path,$x,''),
for $x in $file//date[@status][normalize-space(@status)][@status =
$statusList][not(@status = $absentDateStatus)][not(@date)] return
local:reportError('DATE0050',$path,$x,''),
(: checks on link elements :)
for $x in $file//link[not(matches(.,'\P{Zs}'))] return
local:reportError('LINK0010',$path,$x,''),
(: checks on area attributes:)
for $x in $file//@area[not(normalize-space())] return
local:reportError('AREA0000',$path,$x/..,''),
for $x in $file//@area[not(. castable as xs:NCName)] return
local:reportError('AREA0001',$path,$x/..,''),
for $x in $file//assembly[@area][normalize-space(@area)][@area castable as
xs:NCName]/@area[not(. = $areasList)] return
local:reportError('AREA0010',$path,$x/..,''),
for $x in $file//*[self::provision or self::commentary or self::decision or
self::agency-doc or self::fragment][@area][normalize-space(@area)][@area
castable as xs:NCName][@area[not(. = $areasList)]]
return local:reportError('AREA0020',$path,$x,''),
for $x in $file//*[self::provision or self::commentary or self::decision or
self::agency-doc][not(@area) or not(normalize-space(@area))] return
local:reportError('AREA0030',$path,$x,''),
for $x in $file//*[self::va-object][not(@area) or
not(normalize-space(@area))] return
local:reportError('AREA0040',$path,$x,''),
for $x in $file//*[self::va-object][@area][normalize-space(@area)][@area
castable as xs:NCName][not(@area = $areasList)] return
local:reportError('AREA0045',$path,$x,''),
for $x in $file//include[@area][normalize-space(@area)][@area castable as
xs:NCName][not(@area = $areasList)] return
local:reportError('AREA0050',$path,$x,''),
for $x in $file//include[@area][normalize-space(@area)][@area castable as
xs:NCName][@area = 'fragments'][not(@cite = ('empty','omitted'))] return
local:reportError('AREA0051',$path,$x,''),
for $x in $file//source[@area][normalize-space(@area)][@area castable as
xs:NCName][not(@area = $areasList)] return
local:reportError('AREA0060',$path,$x,''),
for $x in $file//related-content-ref[@area][normalize-space(@area)][@area
castable as xs:NCName][not(@area = $areasList)] return
local:reportError('AREA0070',$path,$x,''),
for $x in $file//*[@area][normalize-space(@area)][@area castable as
xs:NCName][self::link or self::target][not(@area = $areasList)] return
local:reportError('AREA0080',$path,$x,''),
(:check references:)
for $x in
$file//include[not(map:contains($allLocations,concat(@area,'|',@cite)))]
return local:reportError('REFR0010',$path,$x,''),
for $x in $file//source[not(some $num in $file//num satisfies $num/@cite eq
@cite and $num/ancestor::*[@area][1]/@area eq @area)] return
local:reportError('REFR0020',$path,$x,''),
for $x in $file//related-content-ref[not(some $num in $file//num satisfies
$num/@cite eq @cite and $num/ancestor::*[@area][1]/@area eq @area)] return
local:reportError('REFR0030',$path,$x,''))
return if ($bad/*) then $bad else ()
}</bucket>):
Improper use? Potential bug? Your feedback is welcome:
Contact: basex-talk at mailman.uni-konstanz.de
Version: BaseX 7.7 beta
Java: Oracle Corporation, 1.7.0_09
OS: Linux, amd64
Stack Trace:
java.lang.NullPointerException
org.basex.query.var.StaticVarRef.uses(StaticVarRef.java:61) org.basex.query.expr.Arr.uses(Arr.java:45)
org.basex.query.func.FNMap.uses(FNMap.java:137)
org.basex.query.expr.Arr.uses(Arr.java:45)
org.basex.query.path.Step.get(Step.java:55)
org.basex.query.QueryParser.axisStep(QueryParser.java:1950) org.basex.query.QueryParser.step(QueryParser.java:1896)
org.basex.query.QueryParser.relativePath(QueryParser.java:1845) org.basex.query.QueryParser.path(QueryParser.java:1819)
org.basex.query.QueryParser.value(QueryParser.java:1699)
org.basex.query.QueryParser.unary(QueryParser.java:1686)
org.basex.query.QueryParser.cast(QueryParser.java:1664)
org.basex.query.QueryParser.castable(QueryParser.java:1652) org.basex.query.QueryParser.treat(QueryParser.java:1640)
org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) org.basex.query.QueryParser.intersect(QueryParser.java:1607) org.basex.query.QueryParser.union(QueryParser.java:1581)
org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) org.basex.query.QueryParser.additive(QueryParser.java:1550) org.basex.query.QueryParser.range(QueryParser.java:1539)
org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) org.basex.query.QueryParser.ftContains(QueryParser.java:1499) org.basex.query.QueryParser.comparison(QueryParser.java:1481) org.basex.query.QueryParser.and(QueryParser.java:1467)
org.basex.query.QueryParser.or(QueryParser.java:1453)
org.basex.query.QueryParser.single(QueryParser.java:1032)
org.basex.query.QueryParser.forClause(QueryParser.java:1179) org.basex.query.QueryParser.initialClause(QueryParser.java:1149) org.basex.query.QueryParser.flwor(QueryParser.java:1048)
org.basex.query.QueryParser.single(QueryParser.java:1021)
org.basex.query.QueryParser.expr(QueryParser.java:1010)
org.basex.query.QueryParser.parenthesized(QueryParser.java:2291) org.basex.query.QueryParser.primary(QueryParser.java:2054) org.basex.query.QueryParser.postfix(QueryParser.java:2014) org.basex.query.QueryParser.step(QueryParser.java:1895)
org.basex.query.QueryParser.path(QueryParser.java:1811)
org.basex.query.QueryParser.value(QueryParser.java:1699)
org.basex.query.QueryParser.unary(QueryParser.java:1686)
org.basex.query.QueryParser.cast(QueryParser.java:1664)
org.basex.query.QueryParser.castable(QueryParser.java:1652) org.basex.query.QueryParser.treat(QueryParser.java:1640)
org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) org.basex.query.QueryParser.intersect(QueryParser.java:1607) org.basex.query.QueryParser.union(QueryParser.java:1581)
org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) org.basex.query.QueryParser.additive(QueryParser.java:1550) org.basex.query.QueryParser.range(QueryParser.java:1539)
org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) org.basex.query.QueryParser.ftContains(QueryParser.java:1499) org.basex.query.QueryParser.comparison(QueryParser.java:1481) org.basex.query.QueryParser.and(QueryParser.java:1467)
org.basex.query.QueryParser.or(QueryParser.java:1453)
org.basex.query.QueryParser.single(QueryParser.java:1032)
org.basex.query.QueryParser.letClause(QueryParser.java:1205) org.basex.query.QueryParser.initialClause(QueryParser.java:1148) org.basex.query.QueryParser.flwor(QueryParser.java:1048)
org.basex.query.QueryParser.single(QueryParser.java:1021)
org.basex.query.QueryParser.iff(QueryParser.java:1443)
org.basex.query.QueryParser.single(QueryParser.java:1025)
org.basex.query.QueryParser.flwor(QueryParser.java:1130)
org.basex.query.QueryParser.single(QueryParser.java:1021)
org.basex.query.QueryParser.expr(QueryParser.java:1001)
org.basex.query.QueryParser.enclosed(QueryParser.java:990) org.basex.query.QueryParser.dirElemContent(QueryParser.java:2541) org.basex.query.QueryParser.dirElement(QueryParser.java:2487) org.basex.query.QueryParser.constructor(QueryParser.java:2371) org.basex.query.QueryParser.primary(QueryParser.java:2056) org.basex.query.QueryParser.postfix(QueryParser.java:2014) org.basex.query.QueryParser.step(QueryParser.java:1895)
org.basex.query.QueryParser.path(QueryParser.java:1811)
org.basex.query.QueryParser.value(QueryParser.java:1699)
org.basex.query.QueryParser.unary(QueryParser.java:1686)
org.basex.query.QueryParser.cast(QueryParser.java:1664)
org.basex.query.QueryParser.castable(QueryParser.java:1652) org.basex.query.QueryParser.treat(QueryParser.java:1640)
org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) org.basex.query.QueryParser.intersect(QueryParser.java:1607) org.basex.query.QueryParser.union(QueryParser.java:1581)
org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) org.basex.query.QueryParser.additive(QueryParser.java:1550) org.basex.query.QueryParser.range(QueryParser.java:1539)
org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) org.basex.query.QueryParser.ftContains(QueryParser.java:1499) org.basex.query.QueryParser.comparison(QueryParser.java:1481) org.basex.query.QueryParser.and(QueryParser.java:1467)
org.basex.query.QueryParser.or(QueryParser.java:1453)
org.basex.query.QueryParser.single(QueryParser.java:1032)
org.basex.query.QueryParser.argumentList(QueryParser.java:2352) org.basex.query.QueryParser.functionCall(QueryParser.java:2308) org.basex.query.QueryParser.primary(QueryParser.java:2063) org.basex.query.QueryParser.postfix(QueryParser.java:2014) org.basex.query.QueryParser.step(QueryParser.java:1895)
org.basex.query.QueryParser.path(QueryParser.java:1811)
org.basex.query.QueryParser.value(QueryParser.java:1699)
org.basex.query.QueryParser.unary(QueryParser.java:1686)
org.basex.query.QueryParser.cast(QueryParser.java:1664)
org.basex.query.QueryParser.castable(QueryParser.java:1652) org.basex.query.QueryParser.treat(QueryParser.java:1640)
org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) org.basex.query.QueryParser.intersect(QueryParser.java:1607) org.basex.query.QueryParser.union(QueryParser.java:1581)
org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) org.basex.query.QueryParser.additive(QueryParser.java:1550) org.basex.query.QueryParser.range(QueryParser.java:1539)
org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) org.basex.query.QueryParser.ftContains(QueryParser.java:1499) org.basex.query.QueryParser.comparison(QueryParser.java:1481) org.basex.query.QueryParser.and(QueryParser.java:1467)
org.basex.query.QueryParser.or(QueryParser.java:1453)
org.basex.query.QueryParser.single(QueryParser.java:1032)
org.basex.query.QueryParser.flwor(QueryParser.java:1130)
org.basex.query.QueryParser.single(QueryParser.java:1021)
org.basex.query.QueryParser.expr(QueryParser.java:1001)
org.basex.query.QueryParser.parseMain(QueryParser.java:176) org.basex.query.QueryContext.parse(QueryContext.java:176)
org.basex.query.QueryProcessor.parse(QueryProcessor.java:53) org.basex.core.cmd.AQuery.updating(AQuery.java:137)
org.basex.core.cmd.AQuery.updating(AQuery.java:223)
org.basex.gui.GUI.exec(GUI.java:384)
org.basex.gui.GUI$7.run(GUI.java:349)
CG
Hi Graydon,
your (not that horrible) code should work again; please try the latest snapshot [1].
Thanks,
Christian
[1] http://files.basex.org/releases/latest/
Quoted text · Christian Grün · 417 lines
On Tue, May 7, 2013 at 7:08 PM, Christian Grün <christian.gruen at gmail.com> wrote: > Hi Graydon, > > thanks for the report; we can reproduce the problem and give you > notice as soon as it’s fixed. Feel free to follow the issue at GitHub > [1]. > > Best, > Christian > > [1] https://github.com/BaseXdb/basex/issues/696 > ___________________________ > > On Tue, May 7, 2013 at 5:34 PM, Graydon Saunders <graydonish at gmail.com> wrote: >> Running BaseX77-20130503.190321 >> >> The horrible query works until I add the second ("local:addArea") function >> to it; that works fine in its own smaller query, which I've attached. (as >> far as I can tell, it really is the function causing the problem.) >> >> I've attached the horrible query as well, just in case it's not all in the >> error message. >> >> The GUI is showing me "OK" in the bottom left corner. >> >> Contents of error popup: >> >> Could not execute XQUERY declare function local:addArea($area as >> xs:string,$uri as xs:string,$path as xs:string,$element as element()) { >> >> element {node-name($element)} >> { >> $element/@*, >> attribute {'area'} {$area}, >> attribute {'uri'} {$uri}, >> attribute {'path'} {$path}, >> $element/node() >> } >> }; >> >> declare function local:reportError($type as xs:string,$file as >> xs:anyURI,$match as item(),$addInfo as item()*) >> as element(error) { >> >> let $errorMsg := >> <messages> >> <msg><type>BASE0000</type><words>Document loaded into collection is not a >> WKNA-Shared-CMS.dtd document; document element is not >> wkna-shared-cms</words></msg> >> <msg><type>CITE0000</type><words>Cite attribute values are required to >> contain non-whitespace characters</words></msg> >> <msg><type>CITE0005</type><words>Cite attribute value contains characters >> not permitted in cite attribute values</words></msg> >> <msg><type>CITE0010</type><words>num element must have at least one of an >> associated cite attribute with a non-whitespace string value or >> non-whitespace string-contents</words></msg> >> <msg><type>CITE0020</type><words>num element with associated type attribute >> with value "heading" has been deprecated and is not permitted</words></msg> >> <msg><type>CITE0030</type><words>duplicate locative citations</words></msg> >> <msg><type>FILE0010</type><words>document-defining element area-cite pair >> does not match basename component of pathname</words></msg> >> <msg><type>DATE0010</type><words>date element has no associated status >> attribute or status attribute value</words></msg> >> <msg><type>DATE0020</type><words>date element has an associated date >> attribute with a null value</words></msg> >> <msg><type>DATE0030</type><words>date element has an associated date >> attribute with a value outside the permissible date range</words></msg> >> <msg><type>DATE0040</type><words>date element has an associated status >> attribute value not on the permitted list of status values</words></msg> >> <msg><type>DATE0050</type><words>date element has no associated date >> attribute while having a status value which does not permit the date >> attribute to be absent</words></msg> >> <msg><type>AREA0000</type><words>area attribute with no value</words></msg> >> <msg><type>AREA0001</type><words>area attribute value does not conform to >> NCName type restrictions</words></msg> >> <msg><type>AREA0010</type><words>area attribute associated with an assembly >> element has a value which is not a defined area</words></msg> >> <msg><type>AREA0020</type><words>area attribute associated with a >> horizon-level element has a value which is not a defined area</words></msg> >> <msg><type>AREA0030</type><words>area attribute NOT associated with a >> horizon-level element</words></msg> >> <msg><type>AREA0040</type><words>area attribute NOT associated with a >> feature horizon-level element</words></msg> >> <msg><type>AREA0045</type><words>area attribute associated with a feature >> horizon-level element has a value which is not a defined area</words></msg> >> <msg><type>AREA0050</type><words>area attribute associated with an include >> element has a value which is not a defined area</words></msg> >> <msg><type>AREA0051</type><words>include element with special-case >> associated area attribute value "fragments" has an associated cite attribute >> with a value OTHER THAN "empty" or "omitted" which is not >> permitted</words></msg> >> <msg><type>AREA0060</type><words>area attribute associated with a source >> element has a value which is not a defined area</words></msg> >> <msg><type>AREA0070</type><words>area attribute associated with a >> related-content-ref element has a value which is not a defined >> area</words></msg> >> <msg><type>AREA0080</type><words>area attribute associated with a link-type >> element has a value which is not a defined area</words></msg> >> <msg><type>REFR0010</type><words>include elements must reference an existing >> locative citation</words></msg> >> <msg><type>REFR0020</type><words>source elements must reference a locative >> citation (area-cite pair) which exists in the same document</words></msg> >> <msg><type>REFR0030</type><words>related-content-ref elements must reference >> a locative citation (area-cite pair) which exists in the same >> document</words></msg> >> <msg><type>LINK0010</type><words>link elements must have a non-whitespace >> string value</words></msg> >> </messages> >> >> return >> >> >> <error type="{xs:NCName($type)}"> >> <uri>{$file}</uri> >> <description>{string($errorMsg/msg[type eq $type]/words)} >> {if (normalize-space($addInfo) or $addInfo instance of node()) then $addInfo >> else ()}</description> >> <path>{replace(path($match),'/Q\{[^\}]*\}','/')}</path> >> {if ($match[self::element() and (self::assembly or self::va-object or >> self::provision or self::agency-doc or self::commentary or self::decision or >> self::fragment or self::index)]) >> then element {name($match)} {$match/@area} >> else $match} >> </error> >> }; >> >> (: definitions for cite and cite-related checks:) >> >> let $citeChars := >> 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.(),'/[]%:|⦅ÀÂÇÉÈÊËÎÏÔÛÙÜŸÑàâçéèêëîïôûùüÿñœ ' >> >> (: definitions for date checks :) >> let $dateStart := xs:date('1900-01-01') >> let $dateEnd := current-date() + xs:yearMonthDuration('P5Y0M') >> let $statusList := ('active', 'amended', 'archived', 'cancelled', >> 'consolidated', 'effective', 'first-reading', 'former', 'heard', 'oral', >> 'published', 'released', 'repealed', 'replaced', 'resolved', 'reviewed', >> 'revised', 'revoked', 'royal-assent', 'written') >> let $absentDateStatus := >> ('amended','archived','former','repealed','revoked') >> >> (: definitions for area checks :) >> let $areasList := >> doc(concat('file:',string-join(tokenize(substring-after(static-base-uri(),':'),'/')[not(position() >> = (last(),last() >> -1))],'/'),'/XSLT/DTDs/areas-metadata.xml'))/wkna-shared-cms/area/@area >> >> (: definitions for reference checks :) >> let $locativeNums := for $x in collection()//num[ancestor::*[@area][@area >> castable as >> xs:NCName]][@cite][matches(@cite,'\P{Zs}')][translate(@cite,$citeChars,'') >> eq ''] >> return local:addArea($x/ancestor::*[@area][@area castable as >> xs:NCName][1]/@area/string(),base-uri($x),replace(path($x),'/Q\{[^\}]*\}','/'),$x) >> >> let $sortedNums := for $x in $locativeNums order by $x/@area,$x/@cite return >> $x >> >> (: perform actual checks:) >> return file:write('/home/graydon/checks.xml', >> <bucket> >> { >> for tumbling window $w in $sortedNums >> start $s previous $pitem when concat($s/@area,'|',$s/@cite) ne >> concat($pitem/@area,'|',$pitem/@cite) >> return if ($w[2]) then local:reportError('CITE0030','',$w,'') else () >> } >> { >> for $file in collection() >> let $path := document-uri($file) >> >> return >> if (not($file/wkna-shared-cms)) >> then local:reportError('BASE0000',$path,'','') >> >> else >> let $bad := ( >> (:check area + primary cite matches file name :) >> for $x in $file/wkna-shared-cms/*[self::assembly or self::provision or >> self::decision or self::agency-doc or self::commentary or self::fragment or >> self::index][1] >> return >> if >> ($x!concat(@area,'+',replace(replace(translate(translate(num[@cite][1]/@cite,'ÀÂÇÉÈÊËÎÏÔÛÙÜŸÑàâçéèêëîïôûùüÿñ','AACEEEEIIOUUUYNaaceeeeiiouuuyn'),' >> /[]%:','______'),'_+','_'),'^_+|_+$',''),'.xml') eq >> tokenize($path,'/')[last()]) >> then () >> else local:reportError('FILE0010',$path,$x,$x/num[@cite][1]), >> >> (: checks on cite values :) >> for $x in $file//@cite[not(matches(.,'\P{Zs}'))] return >> local:reportError('CITE0000',$path,$x/..,''), >> for $x in $file//@cite[matches(.,'\P{Zs}')][translate(.,$citeChars,'') ne >> ''] return local:reportError('CITE0005',$path,$x/..,concat(' The characters >> ',translate($x,$citeChars,''),' are not permitted in cite attribute >> values.')), >> >> (: checks on num elements:) >> for $x in $file//num[not(normalize-space(@cite) or matches(.,'\P{Zs}'))] >> return local:reportError('CITE0010',$path,$x,''), >> for $x in $file//num[@type eq 'heading'] return >> local:reportError('CITE0020',$path,$x,''), >> >> (: checks on date elements :) >> for $x in $file//date[not(@status) or not(normalize-space(@status))] return >> local:reportError('DATE0010',$path,$x,''), >> for $x in $file//date[@date][not(normalize-space(@date))] return >> local:reportError('DATE0020',$path,$x,''), >> for $x in $file//date[@date castable as xs:date or @date castable as >> xs:gYear or @date castable as xs:gYearMonth] >> let $compare := if ($x/@date castable as xs:date) then xs:date($x/@date) >> else if ($x/@date castable as xs:gYearMonth) then >> xs:date(concat(xs:string(xs:gYearMonth($x/@date)),'-01')) >> else xs:date(concat(xs:string(xs:gYear($x/@date)),'-01-01')) >> >> return if ($compare lt $dateStart or $compare gt $dateEnd) then >> local:reportError('DATE0030',$path,$x,concat('Permissible dates lie betwee >> ',$dateStart,' and ',$dateEnd,' inclusive.')) else (), >> >> for $x in $file//date[@status][normalize-space(@status)][not(@status = >> $statusList)] return local:reportError('DATE0040',$path,$x,''), >> for $x in $file//date[@status][normalize-space(@status)][@status = >> $statusList][not(@status = $absentDateStatus)][not(@date)] return >> local:reportError('DATE0050',$path,$x,''), >> >> (: checks on link elements :) >> for $x in $file//link[not(matches(.,'\P{Zs}'))] return >> local:reportError('LINK0010',$path,$x,''), >> >> (: checks on area attributes:) >> for $x in $file//@area[not(normalize-space())] return >> local:reportError('AREA0000',$path,$x/..,''), >> for $x in $file//@area[not(. castable as xs:NCName)] return >> local:reportError('AREA0001',$path,$x/..,''), >> for $x in $file//assembly[@area][normalize-space(@area)][@area castable as >> xs:NCName]/@area[not(. = $areasList)] return >> local:reportError('AREA0010',$path,$x/..,''), >> for $x in $file//*[self::provision or self::commentary or self::decision or >> self::agency-doc or self::fragment][@area][normalize-space(@area)][@area >> castable as xs:NCName][@area[not(. = $areasList)]] >> return local:reportError('AREA0020',$path,$x,''), >> for $x in $file//*[self::provision or self::commentary or self::decision or >> self::agency-doc][not(@area) or not(normalize-space(@area))] return >> local:reportError('AREA0030',$path,$x,''), >> for $x in $file//*[self::va-object][not(@area) or >> not(normalize-space(@area))] return >> local:reportError('AREA0040',$path,$x,''), >> for $x in $file//*[self::va-object][@area][normalize-space(@area)][@area >> castable as xs:NCName][not(@area = $areasList)] return >> local:reportError('AREA0045',$path,$x,''), >> for $x in $file//include[@area][normalize-space(@area)][@area castable as >> xs:NCName][not(@area = $areasList)] return >> local:reportError('AREA0050',$path,$x,''), >> for $x in $file//include[@area][normalize-space(@area)][@area castable as >> xs:NCName][@area = 'fragments'][not(@cite = ('empty','omitted'))] return >> local:reportError('AREA0051',$path,$x,''), >> for $x in $file//source[@area][normalize-space(@area)][@area castable as >> xs:NCName][not(@area = $areasList)] return >> local:reportError('AREA0060',$path,$x,''), >> for $x in $file//related-content-ref[@area][normalize-space(@area)][@area >> castable as xs:NCName][not(@area = $areasList)] return >> local:reportError('AREA0070',$path,$x,''), >> for $x in $file//*[@area][normalize-space(@area)][@area castable as >> xs:NCName][self::link or self::target][not(@area = $areasList)] return >> local:reportError('AREA0080',$path,$x,''), >> >> (:check references:) >> for $x in >> $file//include[not(map:contains($allLocations,concat(@area,'|',@cite)))] >> return local:reportError('REFR0010',$path,$x,''), >> for $x in $file//source[not(some $num in $file//num satisfies $num/@cite eq >> @cite and $num/ancestor::*[@area][1]/@area eq @area)] return >> local:reportError('REFR0020',$path,$x,''), >> for $x in $file//related-content-ref[not(some $num in $file//num satisfies >> $num/@cite eq @cite and $num/ancestor::*[@area][1]/@area eq @area)] return >> local:reportError('REFR0030',$path,$x,'') >> >> ) >> >> return if ($bad/*) then $bad else () >> }</bucket>): >> Improper use? Potential bug? Your feedback is welcome: >> Contact: basex-talk at mailman.uni-konstanz.de >> Version: BaseX 7.7 beta >> Java: Oracle Corporation, 1.7.0_09 >> OS: Linux, amd64 >> Stack Trace: >> java.lang.NullPointerException >> org.basex.query.var.StaticVarRef.uses(StaticVarRef.java:61) >> org.basex.query.expr.Arr.uses(Arr.java:45) >> org.basex.query.func.FNMap.uses(FNMap.java:137) >> org.basex.query.expr.Arr.uses(Arr.java:45) >> org.basex.query.path.Step.get(Step.java:55) >> org.basex.query.QueryParser.axisStep(QueryParser.java:1950) >> org.basex.query.QueryParser.step(QueryParser.java:1896) >> org.basex.query.QueryParser.relativePath(QueryParser.java:1845) >> org.basex.query.QueryParser.path(QueryParser.java:1819) >> org.basex.query.QueryParser.value(QueryParser.java:1699) >> org.basex.query.QueryParser.unary(QueryParser.java:1686) >> org.basex.query.QueryParser.cast(QueryParser.java:1664) >> org.basex.query.QueryParser.castable(QueryParser.java:1652) >> org.basex.query.QueryParser.treat(QueryParser.java:1640) >> org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) >> org.basex.query.QueryParser.intersect(QueryParser.java:1607) >> org.basex.query.QueryParser.union(QueryParser.java:1581) >> org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) >> org.basex.query.QueryParser.additive(QueryParser.java:1550) >> org.basex.query.QueryParser.range(QueryParser.java:1539) >> org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) >> org.basex.query.QueryParser.ftContains(QueryParser.java:1499) >> org.basex.query.QueryParser.comparison(QueryParser.java:1481) >> org.basex.query.QueryParser.and(QueryParser.java:1467) >> org.basex.query.QueryParser.or(QueryParser.java:1453) >> org.basex.query.QueryParser.single(QueryParser.java:1032) >> org.basex.query.QueryParser.forClause(QueryParser.java:1179) >> org.basex.query.QueryParser.initialClause(QueryParser.java:1149) >> org.basex.query.QueryParser.flwor(QueryParser.java:1048) >> org.basex.query.QueryParser.single(QueryParser.java:1021) >> org.basex.query.QueryParser.expr(QueryParser.java:1010) >> org.basex.query.QueryParser.parenthesized(QueryParser.java:2291) >> org.basex.query.QueryParser.primary(QueryParser.java:2054) >> org.basex.query.QueryParser.postfix(QueryParser.java:2014) >> org.basex.query.QueryParser.step(QueryParser.java:1895) >> org.basex.query.QueryParser.path(QueryParser.java:1811) >> org.basex.query.QueryParser.value(QueryParser.java:1699) >> org.basex.query.QueryParser.unary(QueryParser.java:1686) >> org.basex.query.QueryParser.cast(QueryParser.java:1664) >> org.basex.query.QueryParser.castable(QueryParser.java:1652) >> org.basex.query.QueryParser.treat(QueryParser.java:1640) >> org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) >> org.basex.query.QueryParser.intersect(QueryParser.java:1607) >> org.basex.query.QueryParser.union(QueryParser.java:1581) >> org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) >> org.basex.query.QueryParser.additive(QueryParser.java:1550) >> org.basex.query.QueryParser.range(QueryParser.java:1539) >> org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) >> org.basex.query.QueryParser.ftContains(QueryParser.java:1499) >> org.basex.query.QueryParser.comparison(QueryParser.java:1481) >> org.basex.query.QueryParser.and(QueryParser.java:1467) >> org.basex.query.QueryParser.or(QueryParser.java:1453) >> org.basex.query.QueryParser.single(QueryParser.java:1032) >> org.basex.query.QueryParser.letClause(QueryParser.java:1205) >> org.basex.query.QueryParser.initialClause(QueryParser.java:1148) >> org.basex.query.QueryParser.flwor(QueryParser.java:1048) >> org.basex.query.QueryParser.single(QueryParser.java:1021) >> org.basex.query.QueryParser.iff(QueryParser.java:1443) >> org.basex.query.QueryParser.single(QueryParser.java:1025) >> org.basex.query.QueryParser.flwor(QueryParser.java:1130) >> org.basex.query.QueryParser.single(QueryParser.java:1021) >> org.basex.query.QueryParser.expr(QueryParser.java:1001) >> org.basex.query.QueryParser.enclosed(QueryParser.java:990) >> org.basex.query.QueryParser.dirElemContent(QueryParser.java:2541) >> org.basex.query.QueryParser.dirElement(QueryParser.java:2487) >> org.basex.query.QueryParser.constructor(QueryParser.java:2371) >> org.basex.query.QueryParser.primary(QueryParser.java:2056) >> org.basex.query.QueryParser.postfix(QueryParser.java:2014) >> org.basex.query.QueryParser.step(QueryParser.java:1895) >> org.basex.query.QueryParser.path(QueryParser.java:1811) >> org.basex.query.QueryParser.value(QueryParser.java:1699) >> org.basex.query.QueryParser.unary(QueryParser.java:1686) >> org.basex.query.QueryParser.cast(QueryParser.java:1664) >> org.basex.query.QueryParser.castable(QueryParser.java:1652) >> org.basex.query.QueryParser.treat(QueryParser.java:1640) >> org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) >> org.basex.query.QueryParser.intersect(QueryParser.java:1607) >> org.basex.query.QueryParser.union(QueryParser.java:1581) >> org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) >> org.basex.query.QueryParser.additive(QueryParser.java:1550) >> org.basex.query.QueryParser.range(QueryParser.java:1539) >> org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) >> org.basex.query.QueryParser.ftContains(QueryParser.java:1499) >> org.basex.query.QueryParser.comparison(QueryParser.java:1481) >> org.basex.query.QueryParser.and(QueryParser.java:1467) >> org.basex.query.QueryParser.or(QueryParser.java:1453) >> org.basex.query.QueryParser.single(QueryParser.java:1032) >> org.basex.query.QueryParser.argumentList(QueryParser.java:2352) >> org.basex.query.QueryParser.functionCall(QueryParser.java:2308) >> org.basex.query.QueryParser.primary(QueryParser.java:2063) >> org.basex.query.QueryParser.postfix(QueryParser.java:2014) >> org.basex.query.QueryParser.step(QueryParser.java:1895) >> org.basex.query.QueryParser.path(QueryParser.java:1811) >> org.basex.query.QueryParser.value(QueryParser.java:1699) >> org.basex.query.QueryParser.unary(QueryParser.java:1686) >> org.basex.query.QueryParser.cast(QueryParser.java:1664) >> org.basex.query.QueryParser.castable(QueryParser.java:1652) >> org.basex.query.QueryParser.treat(QueryParser.java:1640) >> org.basex.query.QueryParser.instanceoff(QueryParser.java:1628) >> org.basex.query.QueryParser.intersect(QueryParser.java:1607) >> org.basex.query.QueryParser.union(QueryParser.java:1581) >> org.basex.query.QueryParser.multiplicative(QueryParser.java:1565) >> org.basex.query.QueryParser.additive(QueryParser.java:1550) >> org.basex.query.QueryParser.range(QueryParser.java:1539) >> org.basex.query.QueryParser.stringConcat(QueryParser.java:1525) >> org.basex.query.QueryParser.ftContains(QueryParser.java:1499) >> org.basex.query.QueryParser.comparison(QueryParser.java:1481) >> org.basex.query.QueryParser.and(QueryParser.java:1467) >> org.basex.query.QueryParser.or(QueryParser.java:1453) >> org.basex.query.QueryParser.single(QueryParser.java:1032) >> org.basex.query.QueryParser.flwor(QueryParser.java:1130) >> org.basex.query.QueryParser.single(QueryParser.java:1021) >> org.basex.query.QueryParser.expr(QueryParser.java:1001) >> org.basex.query.QueryParser.parseMain(QueryParser.java:176) >> org.basex.query.QueryContext.parse(QueryContext.java:176) >> org.basex.query.QueryProcessor.parse(QueryProcessor.java:53) >> org.basex.core.cmd.AQuery.updating(AQuery.java:137) >> org.basex.core.cmd.AQuery.updating(AQuery.java:223) >> org.basex.gui.GUI.exec(GUI.java:384) >> org.basex.gui.GUI$7.run(GUI.java:349) >> >> >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >>
Written for BaseX 7.6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery