Salut à tou(te)s,
Je voudrais récupérer par une requête xquery une partie seulement de la valeur d'un attribut dans un fichier xml présenté ainsi:Sauf qu'il y a plusieurs <item> dans le fichier.Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 <item type="fragment" n="1"> <cit dbp:hand="encre"> <quote>bla<choice> <orig><c>&</c></orig> <reg>et</reg> </choice> bablabla <choice> <orig><c>&</c></orig> <reg>et</reg> </choice>bla <lb/>bla. »</quote> <bibl xml:id="b2862-3"><lb/><choice> <abbr>P.</abbr> <expan>P<ex>ère</ex></expan> </choice> Féfé <choice> <abbr>progr.</abbr> <expan><reg>P</reg>an<ex>ès</ex></expan> </choice> par le <choice> <abbr>chr</abbr> <expan>chr<ex>blabla</ex></expan> </choice> (<abbr>t</abbr><supplied>.</supplied> 2. <supplied reason="omission"><abbr>p.</abbr></supplied> 91)</bibl> </cit> </item>
La valeur que je voudrais retourner est en gras. Mais je souhaiterais traiter celle-ci et ne conserver que "2862".
Je pensais donc utiliser la fonction substring() mais je ne comprend pas comment elle fonctionne, même avec les tutos :cry: .
Voici ma requete, qui hors des lignes concernant substring() fonctionne très bien.
Et le message d'erreur (retourné par Exist):Code:
1
2
3
4
5
6
7
8
9
10
11
12
13 declare namespace dbp="http://dossiers-travail/ns/1.0"; for $doc in collection("/db/bdd")/*:TEI for $fragment in $doc//*:div[@*:type="fragment"]|$doc//*:item[@*:type="fragment"] let $bibl3 := data($fragment/descendant-or-self::*:bibl[ends-with(@*:id, "-3")]/@*:id) let $id_b3 := substring($bibl3, 2, 4) let $no_fragment := data($fragment/@n) return <record> <fragment> <bibl3>{$bibl3}</bibl3> <id_b3>{$id_b3}</id_b3> <no_fragment>{$no_fragment}</no_fragment> </fragment> </record>
Merci de votre aideCitation:
An exception occurred during query execution: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: substring($source as xs:string?, $starting-at as xs:double, $length as xs:double) xs:string?. Expected cardinality: zero or one, got 2
org.xmldb.api.base.XMLDBException: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: substring($source as xs:string?, $starting-at as xs:double, $length as xs:double) xs:string?. Expected cardinality: zero or one, got 2.
at org.exist.xmldb.RemoteXPathQueryService.throwException(RemoteXPathQueryService.java:179)
at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:102)
at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:71)
at org.exist.xmldb.RemoteXPathQueryService.execute(RemoteXPathQueryService.java:411)
at org.exist.client.QueryDialog$QueryThread.run(QueryDialog.java:473)
Caused by: org.exist.xquery.XPathException: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: substring($source as xs:string?, $starting-at as xs:double, $length as xs:double) xs:string?. Expected cardinality: zero or one, got 2.
at org.exist.xmldb.RemoteXPathQueryService.throwException(RemoteXPathQueryService.java:178)
... 4 more
Caused by: org.exist.xquery.XPathException: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: substring($source as xs:string?, $starting-at as xs:double, $length as xs:double) xs:string?. Expected cardinality: zero or one, got 2.
at org.exist.xmldb.RemoteXPathQueryService.throwException(RemoteXPathQueryService.java:178)
at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:102)
at org.exist.xmldb.RemoteXPathQueryService.query(RemoteXPathQueryService.java:71)
at org.exist.xmldb.RemoteXPathQueryService.execute(RemoteXPathQueryService.java:411)
at org.exist.client.QueryDialog$QueryThread.run(QueryDialog.java:473)