This discussion is archived
3 Replies Latest reply: Aug 20, 2012 7:03 AM by Ric79 RSS

XPATH pattern

Ric79 Newbie
Currently Being Moderated
Hi all,
let us suppose this XML
    <measData>
        <managedElement localDn="MYNODE" ></managedElement>
        <measInfo>
            <granPeriod duration="PT900S"  endTime="2012-08-20T09:45:00+02:00" ></granPeriod>
            <repPeriod duration="PT900S" ></repPeriod>
            <measType p="1" >ColName1</measType>
            <measType p="2" >ColName2</measType>
            <measType p="3" >ColName3</measType>
            <measType p="4" >ColName4</measType>
            <measType p="5" >ColName5</measType>
            <measType p="6" >ColName6</measType>
            <measValue measObjLdn="measure1,apn=gsm" >
                <r p="1" >100</r>
                <r p="2" >200</r>
                <r p="3" >300</r>
                <r p="4" >400</r>
                <r p="5" >500</r>
                <r p="6" >600</r>
            </measValue>
            <measValue measObjLdn="measure1,apn=umts" >
                <r p="1" >10</r>
                <r p="2" >20</r>
                <r p="3" >30</r>
                <r p="4" >40</r>
                <r p="5" >50</r>
                <r p="6" >60</r>
            </measValue>
        </measInfo> 
    <measData>
I want to select all measValue <b>only if in <repPeriod> duration is "PT900S"</b>.

In PLSQL, i'm using
L_NODELIST   := DBMS_XSLPROCESSOR.SELECTNODES(DBMS_XMLDOM.MAKENODE(L_DOC), 'measData/measInfo/measValue[contains(@measObjLdn,"measure1")]');
...
     DBMS_XSLPROCESSOR.VALUEOF(L_N, '@measObjLdn', T_MYTAB(T_MYTAB.LAST).NAME);
     DBMS_XSLPROCESSOR.VALUEOF(L_N, 'r[@p="1"]/text()', T_MYTAB(T_MYTAB.LAST).COLNAME1);
     DBMS_XSLPROCESSOR.VALUEOF(L_N, 'r[@p="2"]/text()', T_MYTAB(T_MYTAB.LAST).COLNAME2);
     DBMS_XSLPROCESSOR.VALUEOF(L_N, 'r[@p="3"]/text()', T_MYTAB(T_MYTAB.LAST).COLNAME3);
     DBMS_XSLPROCESSOR.VALUEOF(L_N, 'r[@p="4"]/text()', T_MYTAB(T_MYTAB.LAST).COLNAME4);
...
I need to customize the pattern in DBMS_XSLPROCESSOR.SELECTNODES

Thanks to all

Riccardo
  • 1. Re: XPATH pattern
    odie_63 Guru
    Currently Being Moderated
    Hi,
    I need to customize the pattern in DBMS_XSLPROCESSOR.SELECTNODES
    What difficulty are you having?

    You can simply add another XPath predicate, like this :
    measData/measInfo[repPeriod/@duration="PT900S"]/measValue[contains(@measObjLdn,"measure1")]
  • 2. Re: XPATH pattern
    Ric79 Newbie
    Currently Being Moderated
    Thanks,
    this was a really stupid question.

    Riccardo
  • 3. Re: XPATH pattern
    Ric79 Newbie
    Currently Being Moderated
    I'm sorry,
    could you help me another time?

    I need to make dynamic the
    DBMS_XSLPROCESSOR.VALUEOF(L_N, 'r[@p="1"]/text()', T_MYTAB(T_MYTAB.LAST).COLNAME1);
    I would like to obtain -- "@p="1" -- from the
    <measType p="1" >ColName1</measType> 
    Something like this:
    DBMS_XSLPROCESSOR.VALUEOF(L_N, 'r[@p="the number of attribute <p> obtained from related measType having value ColName1"]/text()', T_MYTAB(T_MYTAB.LAST).COLNAME1);
    -----------

    FOUND:
     DBMS_XSLPROCESSOR.VALUEOF(L_N, 'r[@p=../../measType[text()="ColName1"]/@p]/text()', T_MYTAB(T_MYTAB.LAST).COLNAME1);
    Edited by: Ric79 on Aug 20, 2012 4:02 PM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points