developers

    Forum Stats

  • 3,873,642 Users
  • 2,266,620 Discussions
  • 7,911,595 Comments

Discussions

XPATH pattern

Ric79
Ric79 Member Posts: 126
edited Aug 20, 2012 10:03AM in XQuery
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

Best Answer

  • odie_63
    odie_63 Member Posts: 8,493 Silver Trophy
    Answer ✓
    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")]

Answers

  • odie_63
    odie_63 Member Posts: 8,493 Silver Trophy
    Answer ✓
    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")]
  • Ric79
    Ric79 Member Posts: 126
    Thanks,
    this was a really stupid question.

    Riccardo
  • Ric79
    Ric79 Member Posts: 126
    edited Aug 20, 2012 10:03AM
    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=&quot;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
This discussion has been closed.
developers