logo       

Implementation of fn:id() function: msg#00117

Subject: Implementation of fn:id() function
Hello,

I've been trying to use the Xpath v2.0 function fn:id() but it doesn't run well.I don't know if I use it in a bad way or if the Xquery processors don't support it. I think there aren't any encoding problems and I also think I use this function in a good way.

I enclose the files that I use in my examples. The example is very stupid however it's very easy for testing the id() function. I have a xs:IDREFS attribute called "people" in the "departament" element and I want to retrieve their xs:ID that are in the element person. After that, I print whatever to check if I run well.

XML-Document


<?xml version="1.0" encoding="UTF-8"?>
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespaceSchemaLocation="schema.xsd">
 <people>
   <person id="id1" name="John"/>
   <person id="id2" name="Peter"/>
   <person id="id3" name="Anne"/>
 </people>
 <departaments>
   <departament nam="Computer" people="id1 id2"/>
   <departament nam="Business" people="id2 id3"/>
 </departaments>
</document>

XQuery Document

xquery version "1.0";

  <data>{
   for $s in doc("example.xml")/document/departaments/departament
           let $b2:=id($s/@people)/@name
           return <depart>{
           if ($b2='John') then $s/@nam
           else ()
           }</depart>
  }</data>

XML_Schema

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified">
 <xs:element name="departament">
   <xs:complexType>
         <xs:attribute name="nam" type="xs:string" use="required"/>
         <xs:attribute name="people" type="xs:string" use="required"/>
   </xs:complexType>
 </xs:element>
 <xs:element name="departaments">
   <xs:complexType>
     <xs:sequence>
       <xs:element ref="departament" maxOccurs="unbounded"/>
     </xs:sequence>
   </xs:complexType>
 </xs:element>
 <xs:element name="document">
   <xs:complexType>
     <xs:sequence>
       <xs:element ref="people"/>
       <xs:element ref="departaments"/>
     </xs:sequence>
   </xs:complexType>
 </xs:element>
 <xs:element name="people">
   <xs:complexType>
     <xs:sequence>
       <xs:element ref="person" maxOccurs="unbounded"/>
     </xs:sequence>
   </xs:complexType>
 </xs:element>
 <xs:element name="person">
   <xs:complexType>
      <xs:attribute name="id" type="xs:ID" use="required"/>
     <xs:attribute name="name" type="xs:string" use="required"/>
   </xs:complexType>
 </xs:element>
</xs:schema>

Thanks for all,

Luis




-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe