DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   XML, XSLT and XPATH (http://www.daniweb.com/forums/forum134.html)
-   -   XPath or Xquery for Courses.xml (http://www.daniweb.com/forums/thread168685.html)

bullockpasha Jan 16th, 2009 2:07 am
XPath or Xquery for Courses.xml
 
I created a courses.xml file and I want to find the answers for following queries.I am new to xml so I want to know how I can do it.I want to use Xpath or Xquery. Here is the queries i want to find:
1-How can I find find the TA of the network courses that listed in CS department,
taught in spring semester and do not have textbook, and return his/her last name
2-How can I find the CS courses in which a person named Jack served as AI, list the books used in these courses and semesters in which the books are used.

<?xml version="1.0" encoding="ISO‐8859‐1" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="firstname" type="xs:string"/>
<xs:element name="middlename" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<xs:element name="instructor">
<xs:complexType>
<xs:sequence>
<xs:element ref="firstname" minOccur = "0" />
<xs:element ref="middlename" minOccur = "0" maxOccur = "2"/>
<xs:element ref="lastname"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TA">
<xs:complexType>
<xs:sequence>
<xs:element ref="firstname" minOccur = "0" />
<xs:element ref="middlename" minOccur = "0" maxOccur = "2"/>
<xs:element ref="lastname"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="course">
<xs:complexType>
<xs:sequence>
<xs:element name="listingDept" type="xs:string"/>
<xs:element name="courseid" type="xsositiveInteger"/>
<xs:element name="session" maxOccur = "10">
<xs:complexType>
<xs:sequence>
<xs:element ref="instructor"/>
<xs:element ref="TA" minOccur = "0" maxOccur = "2"/>
<xs:element name="book" maxOccur = "6"/>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="title" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="year" type="xs:string"/>
<xs:attribute name="semester" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="title" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="Courses">
<xs:complexType>
<xs:sequence>
<xs:element ref="course"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

fpmurphy Jan 20th, 2009 2:33 pm
Re: XPath or Xquery for Courses.xml
 
What you provided us was an XML schema file. There is no way anybody can help you until you provide an example of your actual XML file containing some sample data.

bullockpasha Jan 20th, 2009 5:51 pm
Re: XPath or Xquery for Courses.xml
 
Well.A courses xml file confirms this schema.It shouldnt be a problem I think.

fpmurphy Jan 22nd, 2009 3:21 pm
Re: XPath or Xquery for Courses.xml
 
Sorry, but without seeing the instantiation of this schema i.e. an actual XML file, nobody is going to be able to help you with your query.

bullockpasha Jan 22nd, 2009 3:50 pm
Re: XPath or Xquery for Courses.xml
 
Thanks.I already did it.


All times are GMT -4. The time now is 11:45 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC