0

I have xml file like this:

<Student CourseTitle="Course1"/>

<Course CourseTitle="Course1" Duration="10"/>

Where CourseTitle in Course tag is key. CourseTitle in Student is keyref. How can I parse this XML document and get Student's course with all attributes in Course tag? Using JAXP? Thanks and sorry for my bad English.

user3435425
  • 192
  • 1
  • 18
  • JAXP provides a wide range of capability including SAX and DOM parsing, XPath, XSLT, and XML Schema processing. It's therefore not clear which technology you actually want to use. However, none of them directly allows you to make use of XSD-defined key/keyref constraints to support a query. – Michael Kay Jul 06 '14 at 17:31

1 Answers1

0

In XSLT, define a key

<xsl:key name="course-key" match="Course" use="CourseTitle"/>

and then if a Student is the context item you can find the corresponding Course using

select="key('course-key', @CourseTitle)
Michael Kay
  • 156,231
  • 11
  • 92
  • 164