This gets me what I was looking for:
<entities>
{
for $org-ref in cts:element-attribute-values( xs:QName( "organization-ref" ),
xs:QName( "uri" ), "", (), () )
return <entity uri="{ $org-ref }">{ doc( "content/lds/organizations.xml"
)//[EMAIL PROTECTED] = $or]/name/text() }</entity>
}
</entities>
Don't know how well it will perform over a large number of organizations, but
that is a problem for tomorrow. Thanks for your help, Danny.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danny Sokolsky
Sent: Monday, August 11, 2008 8:51 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Rationalized element range queries
I don't know of a way to get that list straight from the indexes in 3.2.
What if you just wrapped the XPath with a distinct-values?
let $x := <para>A person name <person-ref
uri="org.lds.people/john-doe">John Doe</person-ref> is the same as a
person named <person-ref uri="org.lds.people/john-doe">Doe,
John</person-ref>.</para>
return
fn:distinct-values($x/person-ref[./@uri eq
"org.lds.people/john-doe"]/text())
With a range index on person-ref/@uri, I think this would be pretty
fast, depending on how many values there are for each URI.
On second thought, I can think of a hacky way you might accomplish this.
You could create another attribute on person-ref that is a concatenation
of the uri attribute and the element value. Something like:
<person-ref uri="org.lds.people/john-doe"
alias="org.lds.people/john-doeZZZZZJohn Doe" >John Doe</person-ref>
Then create an element-attribute index on person-ref/@alias, then use
something like this to return the unique values:
for $x in cts:element-attribute-value-match(xs:QName("person-ref"),
xs:QName("alias"), "org.lds.people/john-doeZZZZZ*")
return fn:substring-after($x, "org.lds.people/john-doeZZZZZ")
(: returns:
Doe, John
John Doe
:)
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stewart
Shelline
Sent: Monday, August 11, 2008 7:14 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Rationalized element range queries
Right: Both elements have the same value for uri, even though they have
different element text nodes, so they are both referring to the same
topic. I would like to be able to do something like an element-values
query that returns unique element text values based on the uri attribute
rather than the element text itself. I know that sounds a little
counterintuitive, but the goal is a rationalized list of terms.
Perhaps a better example would be people:
<para>A person name <person-ref uri="org.lds.people/john-doe">John
Doe</person-ref> is the same as a person named <person-ref
uri="org.lds.people/john-doe">Doe, John</person-ref>.</para>
In this example, we're really talking about just one person, John Doe,
so I would like to see an element value list that contains only one
element--based on the uri attribute, not the element text.
Thinking about it more, though, I guess I could get the effect I want by
doing a join of the results of an element-attribute-values index with a
list of canonical terms. Don't know how well that would perform, though.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Danny
Sokolsky
Sent: Monday, August 11, 2008 7:17 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] Rationalized element range queries
Hi Stewart,
I am not positive I understand your question, but I will give it a try
anyway....
If you use plain XPath, you can use a predicate to constrain on an
attribute and then return the element text nodes. For example:
let $x := <para>The topics <topic-ref
uri="org.lds.topics/gratitude">gratitude</topic-ref> and <topic-ref
uri="org.lds.topics/gratitude">thankfulness</topic-ref> are
similar.</para>
return
$x/topic-ref[./@uri eq "org.lds.topics/gratitude"]/text()
returns:
gratitude
thankfulness
This is part of where I don't understand the question, because you say
it should only be "gratitude". What do you mean by that, as the uri
attribute has the same value for both topic-ref elements?
-Danny
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Stewart
Shelline
Sent: Monday, August 11, 2008 3:10 PM
To: [email protected]
Subject: [MarkLogic Dev General] Rationalized element range queries
Is there a way to constrain the list of element values based on an
attribute of the element? For example, given the XML below:
<para>The topics <topic-ref
uri="org.lds.topics/gratitude">gratitude</topic-ref> and <topic-ref
uri="org.lds.topics/gratitude">thankfulness</topic-ref> are
similar.</para>
I would like to have the index based on the value of the uri attribute
but return the text node from the element. In the case above, that would
mean just one item, "gratitude." It appears that you can create an index
on an element or an attribute, but not a combination.
________________________________________
NOTICE: This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
----------------------------------------------------------------------
NOTICE: This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
----------------------------------------------------------------------
NOTICE: This email message is for the sole use of the intended recipient(s) and
may contain confidential and privileged information. Any unauthorized review,
use, disclosure or distribution is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all copies of
the original message.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general