XPATH query with XML and XSD
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 4
- Joined: Fri Dec 13, 2019 1:32 am
XPATH query with XML and XSD
Hello together, I´ve got the following problem:
As you can see in the following code, I´ve made an studyadministration, in which every study has an ID, that linked to the course of study.
Part of XML-File (Art --> Dual):
Part of .xsd-File:
I´m new to the hole topic, and worked only with elements.
How is it possible by Xpath-querys, to ask how many students are in an study-course, that is "dual"?
So that I can access the ID-data from the associated IDREF-data.
Best regards,
Tobias!
As you can see in the following code, I´ve made an studyadministration, in which every study has an ID, that linked to the course of study.
Part of XML-File (Art --> Dual):
Code: Select all
<Studiengänge>
<StudiengangID>S01</StudiengangID>
<studiengang>Wirtschaft</studiengang>
<charakteristik>Bachelor</charakteristik>
<art>Dual</art>
<Fakultät>F1</Fakultät>
</Studiengänge>
Code: Select all
<student>
<name>Mustermann</name>
<vorname>Lukas-Meyer</vorname>
<matrikelnummer>m502368</matrikelnummer>
<aktuelleHochschule>AH01</aktuelleHochschule>
<StudiengangID>S01</StudiengangID>
<studiumart>Vollzeitstudium</studiumart>
<amStudieren>Nein</amStudieren>
<studienbeginn>2016-03-02</studienbeginn>
<studienende>
<Datum>2019-03-02</Datum>
<Grund>Eigener Wunsch</Grund>
</studienende>
<postadresse>
<vorname>Test</vorname>
<name>Testermann</name>
<straße>Hausstraße</straße>
<hausnummer>11</hausnummer>
<postleitzahl>345678</postleitzahl>
<ort>testort</ort>
<land>DE</land>
</postadresse>
<email>well-formed@web.de</email>
<auslandssemester>
<status>laufend</status>
<HochschulID>H01</HochschulID>
</auslandssemester>
</student>
Code: Select all
<xs:element name="studentenverwaltung" type="studentenverwaltungsTyp"/>
<xs:complexType name="studiengängetyp">
<xs:sequence>
<xs:element name="StudiengangID" type="xs:ID" maxOccurs="unbounded"/>
<xs:element name="studiengang" type="studiengangstyp" maxOccurs="unbounded"/>
<xs:element name="charakteristik" type="charakteristikTyp" maxOccurs="unbounded"/>
<xs:element name="art" type="artType" maxOccurs="unbounded"/>
<xs:element name="Fakultät" type="xs:IDREF" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentenverwaltungsTyp">
<xs:sequence>
<xs:element name="Studiengänge" type="studiengängetyp" maxOccurs="unbounded"/>
<xs:element name="Fakultäten" type="fakultätenTyp" maxOccurs="unbounded"/>
<xs:element name="AuslandsHochschulen" type="auslandshochschulenType" maxOccurs="unbounded"/>
<xs:element name="aktuellehochschule" type="aktuelleHochschule" maxOccurs="unbounded"/>
<xs:element name="student" type="studentTyp" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="studentTyp">
<xs:sequence>
<xs:element name="name" type="namenTyp" minOccurs="1"/>
<xs:element name="vorname" type="namenTyp" minOccurs="0"/>
<xs:element name="matrikelnummer" type="matrikelnummerTyp" minOccurs="1"/>
<xs:element name="aktuelleHochschule" type="xs:IDREF" maxOccurs="1"/>
<xs:element name="StudiengangID" type="xs:IDREF"/>
<xs:element name="studiumart" type="studiumartTyp" minOccurs="1"/>
<xs:element name="amStudieren" type="amStudierenTyp"/>
<xs:element name="studienbeginn" type="datumTyp" minOccurs="1"/>
<xs:element name="studienende" type="studienendeTyp" minOccurs="0"/>
<xs:element name="postadresse" type="postadressenTyp" minOccurs="1"/>
<xs:element name="email" type="emailTyp" minOccurs="1"/>
<xs:element name="zusatzMail" type="emailTyp" maxOccurs="unbounded" minOccurs="0"/>
<xs:element name="auslandssemester" type="auslandssemesterTyp"/>
</xs:sequence>
</xs:complexType>
How is it possible by Xpath-querys, to ask how many students are in an study-course, that is "dual"?
So that I can access the ID-data from the associated IDREF-data.
Best regards,
Tobias!
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XPATH query with XML and XSD
Hi,
The XPath would look like this:
This counts all students that are in all study courses that are Dual. If you want a specific one, or if you want a per study count, you need more complex code. So which one is it?
Regards,
Adrian
The XPath would look like this:
Code: Select all
count(//student[StudiengangID=//Studiengänge[art='Dual']/StudiengangID])
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 4
- Joined: Fri Dec 13, 2019 1:32 am
Re: XPATH query with XML and XSD
Hi Adrian,adrian wrote: ↑Fri Dec 13, 2019 1:24 pm Hi,
The XPath would look like this:This counts all students that are in all study courses that are Dual. If you want a specific one, or if you want a per study count, you need more complex code. So which one is it?Code: Select all
count(//student[StudiengangID=//Studiengänge[art='Dual']/StudiengangID])
Regards,
Adrian
many thanks to you, this is exactly what I was searching for!
Best regards,
Tobias!
Return to “General XML Questions”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service