Jump to content

Xpath in xml file


VagosM
 Share

Recommended Posts

i have write an xml file and his xsd i try to make sql querys by using the keys but i cant take a result.

XMLFILE

<?xml version="1.0" encoding="UTF-8" ?><Record xsi:noNamespaceSchemaLocation="C:UsersvagosDesktopdb.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">	<Conservatory ConservatoryID="C100">		<Name>...</Name>		<Address>			<Street>..</Street>			<Zip>...</Zip>		    <City>...</City>		</Address>	</Conservatory>		<Student StudentID="S100">		<ConservatoryID fkConservatoryID="C100"/>		<Name>...</Name> 		<Address>			<Street>.....</Street>			<Zip>....</Zip>		    <City>.....</City>		</Address>	</Student>		<Teacher TeacherID="T100">		<ConservatoryID fkConservatoryID="C100"/>		<Name>......</Name>		<Name_speciality>....</Name_speciality>	</Teacher>		<Instrument InstrumentID="I100">		<ConservatoryID fkConservatoryID="C100"/>		<TeacherID fkTeacherID="T100"/>		<StudentID fkStudentID="100"/>		<Name>.....</Name>		<InstrumentType>.....</InstrumentType>		</Instrument>		</Record>

The XSD file

<?xml version="1.0" encoding="UTF-8"?><!-- edited with XMLSpy v2009 (http://www.altova.com) by Aruna (Nil) --><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">				<xs:element name="Record" maxOccurs="unbounded">					<xs:complexType>						<xs:sequence>							<xs:element name="Conservatory" maxOccurs="unbounded">								<xs:complexType>									<xs:sequence>										<xs:element name="Name" type="xs:string"/>										<xs:element name="Address" type="AddressType"/>									</xs:sequence>									<xs:attribute name="ConservatoryID" type="xs:string" use="required"/>								</xs:complexType>							</xs:element>							<xs:element name="Student" maxOccurs="unbounded">								<xs:complexType>									<xs:sequence>										<xsd:complexType>                                          <xsd:attribute name="fkConservatoryID" type="xsd:string" use="required"/>                                       </xsd:complexType>										<xs:element name="Name" type="xs:string"/>										<xs:element name="Address" type="AddressType"/>									</xs:sequence>									<xs:attribute ref="StudentID" type="xs:string" use="required"/>								</xs:complexType>							</xs:element>							<xs:element name="Teacher" maxOccurs="unbounded">								<xs:complexType>									<xs:sequence>									    <xsd:complexType>                                          <xsd:attribute name="fkConservatoryID" type="xsd:string" use="required"/>                                        </xsd:complexType>										<xs:element name="Name" type="xs:string"/>										<xs:element name="Name_speciality" type="xs:string"/>									</xs:sequence>									<xs:attribute ref="TeacherID" type="xs:string" use="required"/>								</xs:complexType>							</xs:element>							<xs:element name="Instrument" maxOccurs="unbounded">								<xs:complexType>									<xs:sequence>										<xsd:complexType>                                          <xsd:attribute name="fkConservatoryID" type="xsd:string" use="required"/>										  <xsd:attribute name="fkTeacherID" type="xsd:string" use="required"/>										  <xsd:attribute name="fkStudentID" type="xsd:string" use="required"/>                                        </xsd:complexType>										<xs:element name="Name" type="xs:string"/>										<xs:element name="InstrumentType" type="xs:string"/>									</xs:sequence>									<xs:attribute ref="InstrumentID" type="xs:string" use="required"/>								</xs:complexType>							</xs:element>							<xs:element name="AddressType" maxOccurs="unbounded">								<xs:complexType>									<xs:sequence>										<xs:element name="Street" type="xs:string"/>										<xs:element name="Zip" type="xs:string"/>										<xs:element name="City" type="xs:string"/>									</xs:sequence>								</xs:complexType>							</xs:element>						</xs:sequence>					</xs:complexType>					<xs:key name="PKConservatory">						<xs:selector xpath="Conservatory"/>						<xs:field xpath="@ConservatoryID"/>					</xs:key>					<xs:key name="PKStudent">						<xs:selector xpath="Student"/>						<xs:field xpath="@StudentID"/>					</xs:key>					<xs:key name="PKTeacher">						<xs:selector xpath="Teacher"/>						<xs:field xpath="@TeacherID"/>					</xs:key>					<xs:key name="PKInstrument">						<xs:selector xpath="Instrument"/>						<xs:field xpath="@InstrumentID"/>					</xs:key>					<xs:keyref name="FKStudentToConservatory" refer="PKConservatory">						<xs:selector xpath="Student"/>						<xs:field xpath="@fkConservatoryID"/>					</xs:keyref>					<xs:keyref name="FKTeacherToConservatory" refer="PKConservatory">						<xs:selector xpath="Teacher"/>						<xs:field xpath="@fkConservatoryID"/>					</xs:keyref>					<xs:keyref name="FKInstrumentToConservatory" refer="PKConservatory">						<xs:selector xpath="Instrument"/>						<xs:field xpath="@fkConservatoryID"/>					</xs:keyref>					<xs:keyref name="FKInstrumentToTeacher" refer="PKTeacher">						<xs:selector xpath="Instrument"/>						<xs:field xpath="@fkTeacherID"/>					</xs:keyref>					<xs:keyref name="FKInstrumentToStudent" refer="PKStudent">						<xs:selector xpath="Instrument"/>						<xs:field xpath="@fkStudentID"/>					</xs:keyref>	             </xs:element></xs:schema>
Edited by VagosM
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...