[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

contains function problem

Priscilla Walmsley pwalmsley-lists at datypic.com
Sat Jan 7 10:48:31 PST 2006


contains function
Hi Manolis,

You've got a few problems:

1. In your call to the contains function, the quotes around the path
expression should not be there

2. In your call to the contains function, the path expression has no context
- you need to start it with $x

3. Email needs to be prefixed

4. Leave text() off - it will not work because it will be looking for
textual content right in the Name element, not in any of its children
(FamilyName or GivenName).

5. You've got multiple Name elements within a Semantics element, and the
contains function will only take a single string as its first argument. I
assume you want to test for the Agent's name (and each Agent only has one
Name). So, you could rewrite the query as:

---------------------
xquery version "1.0";
declare namespace Mpeg7="urn:mpeg:mpeg7:schema:2001";

for $x in doc("myPersons.xml")//Mpeg7:Agent
where contains($x/Mpeg7:Name,"Moras")
return $x//Mpeg7:Email
---------------------


Hope that helps,
Priscilla

 ----------------------------------------------------------------- 
Priscilla Walmsley                 http://www.datypic.com 
Author, Definitive XML Schema     (Prentice Hall PTR) 
        Definitive XQuery (coming soon) 
----------------------------------------------------------------- 


________________________________

	From: http://xquery.com/mailman/listinfo/talk [mailto:http://xquery.com/mailman/listinfo/talk] On
Behalf Of Manolis Mylonakis
	Sent: Saturday, January 07, 2006 9:18 AM
	To: http://xquery.com/mailman/listinfo/talk
	Subject:  contains function problem
	
	
	hello,
	 
	i have a problem with 'contains' function of xquery.
	 
	I have the following xml file named myPersons.xml
	 
	 
	 
	 
	 
	<Mpeg7 xmlns="urn:mpeg:mpeg7:schema:2001"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

	<Description xsi:type="SemanticDescriptionType">

	<Semantics>

	<AbstractionLevel dimension="0"/>

	<Label>

	<Name>Soccer Agent Example</Name>

	</Label>

	<Property>

	<Name>Something</Name>

	<Definition>socceragents</Definition>

	</Property>

	<SemanticBase xsi:type="AgentObjectType" id="Moras">

	<AbstractionLevel dimension="0"/>

	<Label>

	<Name>Moras</Name>

	</Label>

	<Definition>

	<FreeTextAnnotation>Vaggelis Moras</FreeTextAnnotation>

	</Definition>

	<Agent xsi:type="PersonType">

	<Name>

	<FamilyName initial="M">Moras</FamilyName>

	<GivenName>Vaggelis</GivenName>

	</Name>

	<ElectronicAddress>

	<Email>http://xquery.com/mailman/listinfo/talk</Email>

	</ElectronicAddress>

	</Agent>

	</SemanticBase>

	</Semantics>

			<Semantics>

	<AbstractionLevel dimension="0"/>

	<Label>

	<Name>Soccer Agent Example</Name>

	</Label>

	<Property>

	<Name>teacher </Name>

	<Definition>university teacher</Definition>

	</Property>

	<SemanticBase xsi:type="AgentObjectType" id="Moras">

	<AbstractionLevel dimension="0"/>

	<Label>

	<Name>Dolas</Name>

	</Label>

	<Definition>

	<FreeTextAnnotation>Apostolos Dolas</FreeTextAnnotation>

	</Definition>

	<Agent xsi:type="PersonType">

	<Name>

	<FamilyName initial="M">Dolas</FamilyName>

	<GivenName>Apostolos</GivenName>

	</Name>

	<ElectronicAddress>

	<Email>http://xquery.com/mailman/listinfo/talk</Email>

	</ElectronicAddress>

	</Agent>

	</SemanticBase>

	</Semantics>

		</Description>

	</Mpeg7>

	 

	 

	 

	 

	 

	I ask for the email address for a person who has a <Name> as Moras
for example...

	my xquery is the following:

	 

	xquery version "1.0";

	declare namespace Mpeg7="urn:mpeg:mpeg7:schema:2001";

	for $x in doc("myPersons.xml")//Mpeg7:Semantics

	where contains("//Mpeg7:Name/text()","Moras")

	return $x//Email

	 

	 

	none results returned

	 

	what is my fault?

	 

	Thanks 

	Manolis

	 

	 

	 




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.