Z
Ziphims
I'm having a problem with XPath's predicate. This is the data I'm
dealing right now:
<?xml version="1.0" encoding="UTF-8"?>
<EMPLOYEE ID="2">
<NAME Src="DB">Alan Smith</NAME>
<SEX Src="DB">M</SEX>
<ADDRESSES>
<ADDRESSITEM EMPID="2">
<NAME Src="DB">Apartment</NAME>
<ADDRESS Src="DB">Orchard Rd.</ADDRESS>
<POSTCODE Src="DB">110000</POSTCODE>
</ADDRESSITEM>
</ADDRESSES>
<BIRTHDATE Src="DB">210038400</BIRTHDATE>
<BIRTHLOCATION Src="DB">Jakarta</BIRTHLOCATION>
<RELATEDDATA>
<RELATIONTYPE ID="3">
<NAME Src="DB">Husband</NAME>
<NAME_R Src="DB">Wife</NAME_R>
</RELATIONTYPE>
<RELATIONTYPE ID="4">
<NAME Src="DB">Friend</NAME>
<NAME_R Src="DB"></NAME_R>
</RELATIONTYPE>
<PEOPLE PID="3">
<NAME Src="DB">Elisha Sue</NAME>
<SEX Src="DB">F</SEX>
</PEOPLE>
<PEOPLE PID="10">
<NAME Src="DB">Robert Thompson</NAME>
<SEX Src="DB">M</SEX>
</PEOPLE>
<PEOPLE PID="13">
<NAME Src="DB">Steven Richard</NAME>
<SEX Src="DB">M</SEX>
</PEOPLE>
</RELATEDDATA>
<PHONENUMBERS>
<NUMBERITEM EMPID="2">
<NAME Src="DB">Cellphone (Work)</NAME>
<NUMBER Src="DB">0835 545856425</NUMBER>
</NUMBERITEM>
<NUMBERITEM EMPID="2">
<NAME Src="DB">Home (Fax)</NAME>
<NUMBER Src="DB">5748963</NUMBER>
</NUMBERITEM>
</PHONENUMBERS>
<RELATIONSHIPS>
<RELITEM>
<PEOPLE1 Src="DB">2</PEOPLE1>
<PEOPLE2 Src="DB">3</PEOPLE2>
<RELTYPE Src="DB">3</RELTYPE>
</RELITEM>
<RELITEM>
<PEOPLE1 Src="DB">2</PEOPLE1>
<PEOPLE2 Src="DB">10</PEOPLE2>
<RELTYPE Src="DB">4</RELTYPE>
</RELITEM>
</RELATIONSHIPS>
</EMPLOYEE>
What I'm trying to do is to get the NAME of a PEOPLE element (part of
RELATEDDATA element) having PID of PEOPLE2 element under a RELITEM
element. So far the only thing that is close to what I want is this
expression:
(using RELITEM element as pivot point)
ancestor::*/RELATEDDATA//NAME[parent:EOPLE/@PID = //PEOPLE2]/
parent:EOPLE
But as you can guess, it select two PEOPLE because I'm using "//". The
thing is, I'm parsing this document for a program (using libxml2) and
it evaluate one RELITEM element at a time. So what I want is to use
the currently 'selected' RELITEM and get PEOPLE element based on
PEOPLE2 element (under the currently 'selected' RELITEM) value.
I've set the pivot element in libxml2 to use the currently 'selected'
RELITEM but I'm not getting any result from this expression:
ancestor::*/RELATEDDATA//NAME[parent:EOPLE/@PID = /PEOPLE2]
All of this led me to a question: Is it possible to use pivot element
in libxml inside a predicate? If yes, how?
I'm open to any suggestion, word of wisdom, advice, link, basically
anything to explain this.
dealing right now:
<?xml version="1.0" encoding="UTF-8"?>
<EMPLOYEE ID="2">
<NAME Src="DB">Alan Smith</NAME>
<SEX Src="DB">M</SEX>
<ADDRESSES>
<ADDRESSITEM EMPID="2">
<NAME Src="DB">Apartment</NAME>
<ADDRESS Src="DB">Orchard Rd.</ADDRESS>
<POSTCODE Src="DB">110000</POSTCODE>
</ADDRESSITEM>
</ADDRESSES>
<BIRTHDATE Src="DB">210038400</BIRTHDATE>
<BIRTHLOCATION Src="DB">Jakarta</BIRTHLOCATION>
<RELATEDDATA>
<RELATIONTYPE ID="3">
<NAME Src="DB">Husband</NAME>
<NAME_R Src="DB">Wife</NAME_R>
</RELATIONTYPE>
<RELATIONTYPE ID="4">
<NAME Src="DB">Friend</NAME>
<NAME_R Src="DB"></NAME_R>
</RELATIONTYPE>
<PEOPLE PID="3">
<NAME Src="DB">Elisha Sue</NAME>
<SEX Src="DB">F</SEX>
</PEOPLE>
<PEOPLE PID="10">
<NAME Src="DB">Robert Thompson</NAME>
<SEX Src="DB">M</SEX>
</PEOPLE>
<PEOPLE PID="13">
<NAME Src="DB">Steven Richard</NAME>
<SEX Src="DB">M</SEX>
</PEOPLE>
</RELATEDDATA>
<PHONENUMBERS>
<NUMBERITEM EMPID="2">
<NAME Src="DB">Cellphone (Work)</NAME>
<NUMBER Src="DB">0835 545856425</NUMBER>
</NUMBERITEM>
<NUMBERITEM EMPID="2">
<NAME Src="DB">Home (Fax)</NAME>
<NUMBER Src="DB">5748963</NUMBER>
</NUMBERITEM>
</PHONENUMBERS>
<RELATIONSHIPS>
<RELITEM>
<PEOPLE1 Src="DB">2</PEOPLE1>
<PEOPLE2 Src="DB">3</PEOPLE2>
<RELTYPE Src="DB">3</RELTYPE>
</RELITEM>
<RELITEM>
<PEOPLE1 Src="DB">2</PEOPLE1>
<PEOPLE2 Src="DB">10</PEOPLE2>
<RELTYPE Src="DB">4</RELTYPE>
</RELITEM>
</RELATIONSHIPS>
</EMPLOYEE>
What I'm trying to do is to get the NAME of a PEOPLE element (part of
RELATEDDATA element) having PID of PEOPLE2 element under a RELITEM
element. So far the only thing that is close to what I want is this
expression:
(using RELITEM element as pivot point)
ancestor::*/RELATEDDATA//NAME[parent:EOPLE/@PID = //PEOPLE2]/
parent:EOPLE
But as you can guess, it select two PEOPLE because I'm using "//". The
thing is, I'm parsing this document for a program (using libxml2) and
it evaluate one RELITEM element at a time. So what I want is to use
the currently 'selected' RELITEM and get PEOPLE element based on
PEOPLE2 element (under the currently 'selected' RELITEM) value.
I've set the pivot element in libxml2 to use the currently 'selected'
RELITEM but I'm not getting any result from this expression:
ancestor::*/RELATEDDATA//NAME[parent:EOPLE/@PID = /PEOPLE2]
All of this led me to a question: Is it possible to use pivot element
in libxml inside a predicate? If yes, how?
I'm open to any suggestion, word of wisdom, advice, link, basically
anything to explain this.