[Bug 5024] sml:keyref example

http://www.w3.org/Bugs/Public/show_bug.cgi?id=5024

           Summary: sml:keyref example
           Product: SML
           Version: FPWD
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
        AssignedTo: cmsmcq@w3.org
        ReportedBy: sandygao@ca.ibm.com
         QAContact: public-sml@w3.org


Section 4.4.3 has the following example:

  <sml:key name="StudentIDisKey">
    <sml:selector xpath="smlfn:deref(tns:Students/tns:Student)"/>
    <sml:field xpath="tns:ID"/>  
  </sml:key>  
  <sml:keyref name="CourseStudents" refer="tns:StudentIDisKey">
    <sml:selector xpath="smlfn:deref(
                         smlfn:deref(tns:Courses/tns:Course)/
                         tns:EnrolledStudents/tns:EnrolledStudent)"/>
    <sml:field xpath="tns:ID"/>
  </sml:keyref>

Note that "selector" in <keyref> has 2 deref()s in it. The inner one gets to
individual courses, and the outer one derefs to students. This mean that key
and keyref select from the same set of elements.

This of course makes the keyref *always* satisfied (ID of student A is the same
as ID of student A). Note that key/keyref are normally used when element A
refers to a different element B.

Would this example be more illustrative if "EnrolledStudent" wasn't a reference
but rather had an "ID" child, and the outer deref() was removed from the keyref
selector?

    <sml:selector xpath="smlfn:deref(tns:Courses/tns:Course)/
                         tns:EnrolledStudents/tns:EnrolledStudent"/>

Received on Thursday, 6 September 2007 16:30:05 UTC