function idref() and one-to-many
Monday, 3 February 2014 · 4 messages
TG
Tsvetanka Georgieva-Trifonova3 Feb 2014 09:17 #
Thank you for your answer!
But this solution does not work with one-to-many
relationships.
When I run the following script:
let $i := <root>
<a id = "a1" idref =
"b1"> aaa1</a>
<a id = "a2" idef =
"b1">aaa2</a>
<a id = "a3" idef=
"b2"> aaa3</a>
<a id = "a11" idref =
"b2"> aaa11</a>
<b id = "b1" idref = "a1
a2">bb1</b>
<b id = "b2" idref = "a3
a11">bb2</b>
</root>
return
$i/*[matches(@idref, 'a1')]
BaseX produces the result:
<b id="b1"
idref="a1 a2">bb1</b>
<b id="b2"
idref="a3 a11">bb2</b>
that is different from: <b id="b1" idref="a1
a2">bb1</b>Besides, my question is about the function idref()? Is
it supported?
I find some examples here: http://www.xqueryfunctions.com/xq/fn_idref.html I have defined DTD, schema, but the result is the
same.
BaseX requires the name of the attribute-identifier to contain “id” and the name of the attribute with references to contain ‘idref’. But the function idref() returns result only if the relationship is one-to-one. I would be grateful if you tell me how to apply the
function idref() when the relationship is one-to-many.
Best regards,
Tsvetanka
CG
Christian Grün3 Feb 2014 10:50 #
Hi Tsvetanka,
Quoted text · Tsvetanka Georgieva-Trifonova · 5 lines
> BaseX produces the result: > > <b id="b1" idref="a1 a2">bb1</b> > <b id="b2" idref="a3 a11">bb2</b> > that is different from: <b id="b1" idref="a1 a2">bb1</b>
The following line of code will give you the expected results (but it may not be efficient enough for large documents):
return $xml/*[tokenize(@idref, '\s') = 'a1']
Quoted text · Tsvetanka Georgieva-Trifonova · 1 line
> Besides, my question is about the function idref()? Is it supported?
As BaseX works without schema support, id() and idref() also return results for XML documents that have no schema attached.
Quoted text · Tsvetanka Georgieva-Trifonova · 3 lines
> BaseX requires the name of the attribute-identifier to contain "id" and the > name of the attribute with references to contain 'idref'. But the function > idref() returns result only if the relationship is one-to-one.
True. I will have a closer look at this. Let's see what we can do!
Thanks for your observation,
Christian
CG
Hi Tsvetanka,
the latest stable snapshot should resolve the idref issues that you encountered [1].
Your feedback is welcome,
Christian
[1] http://files.basex.org/releases/latest/
Quoted text · Tsvetanka Georgieva-Trifonova · 37 lines
On Mon, Feb 3, 2014 at 8:17 AM, Tsvetanka Georgieva-Trifonova <cvetygeorg at yahoo.com> wrote: > Thank you for your answer! > But this solution does not work with one-to-many relationships. > When I run the following script: > let $i := <root> > <a id = "a1" idref = "b1"> aaa1</a> > <a id = "a2" idef = "b1">aaa2</a> > <a id = "a3" idef= "b2"> aaa3</a> > <a id = "a11" idref = "b2"> aaa11</a> > <b id = "b1" idref = "a1 a2">bb1</b> > <b id = "b2" idref = "a3 a11">bb2</b> > </root> > return $i/*[matches(@idref, 'a1')] > > BaseX produces the result: > > <b id="b1" idref="a1 a2">bb1</b> > <b id="b2" idref="a3 a11">bb2</b> > that is different from: <b id="b1" idref="a1 a2">bb1</b> > > Besides, my question is about the function idref()? Is it supported? > I find some examples here: http://www.xqueryfunctions.com/xq/fn_idref.html > I have defined DTD, schema, but the result is the same. > BaseX requires the name of the attribute-identifier to contain "id" and the > name of the attribute with references to contain 'idref'. But the function > idref() returns result only if the relationship is one-to-one. > I would be grateful if you tell me how to apply the function idref() when > the relationship is one-to-many. > Best regards, > Tsvetanka > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
TG
Tsvetanka Georgieva-Trifonova3 Feb 2014 19:27 #
Hi Christian,
Yes, now the function idref() works properly.
Thank you very much!
Tsvetanka
Quoted text · Christian Grün · 1 line
On Monday, February 3, 2014 4:10 PM, Christian Grün <christian.gruen at gmail.com> wrote:
Hi Tsvetanka,
the latest stable snapshot should resolve the idref issues that you encountered [1].
Your feedback is welcome,
Christian
[1] http://files.basex.org/releases/latest/
Quoted text · Tsvetanka Georgieva-Trifonova · 37 lines
On Mon, Feb 3, 2014 at 8:17 AM, Tsvetanka Georgieva-Trifonova <cvetygeorg at yahoo.com> wrote: > Thank you for your answer! > But this solution does not work with one-to-many relationships. > When I run the following script: > let $i := <root> > <a id = "a1" idref = "b1"> aaa1</a> > <a id = "a2" idef = "b1">aaa2</a> > <a id = "a3" idef= "b2"> aaa3</a> > <a id = "a11" idref = "b2"> aaa11</a> > <b id = "b1" idref = "a1 a2">bb1</b> > <b id = "b2" idref = "a3 a11">bb2</b> > </root> > return $i/*[matches(@idref, 'a1')] > > BaseX produces the result: > > <b id="b1" idref="a1 a2">bb1</b> > <b id="b2" idref="a3 a11">bb2</b> > that is different from: <b id="b1" idref="a1 a2">bb1</b> > > Besides, my question is about the function idref()? Is it supported? > I find some examples here: http://www.xqueryfunctions.com/xq/fn_idref.html > I have defined DTD, schema, but the result is the same. > BaseX requires the name of the attribute-identifier to contain "id" and the > name of the attribute with references to contain 'idref'. But the function > idref() returns result only if the relationship is one-to-one. > I would be grateful if you tell me how to apply the function idref() when > the relationship is one-to-many. > Best regards, > Tsvetanka > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
Written for BaseX 7.7. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery