Home » Developer & Programmer » JDeveloper, Java & XML » how do i filter out the node which has attribute value equal empty
how do i filter out the node which has attribute value equal empty [message #415935] Wed, 29 July 2009 17:17 Go to next message
zhefeng
Messages: 4
Registered: July 2009
Junior Member
Like this, i am trying to filter out the ditabuild which has child node ditabuildoutput and its basename attributes is empty:

jehan@RAC10U> select *
  2  from   xmltable(
  3  'for $i in /ditabuilds/ditabuild
  4  where ($i/ditabuildoutput/@basename!="")
  5  return $i'
  6  passing xmltype(
  7  '<ditabuilds>
  8  <ditabuild mount="123" locale="en_us" tail="abc" hash="45678">
  9  <ditabuildoutput basename="test11">value1</ditabuildoutput>
 10  <ditabuildoutput basename="test12">value2</ditabuildoutput>
 11  </ditabuild>
 12  <ditabuild mount="223" locale="en_us" tail="efg" hash="55678">
 13  <ditabuildoutput basename="">value21</ditabuildoutput>
 14  </ditabuild>
 15  <ditabuild mount="323" locale="en_us" tail="hij" hash="65678">
 16  <ditabuildoutput basename="test1">value31</ditabuildoutput>
 17  <ditabuildoutput basename="test2">value32</ditabuildoutput>
 18  </ditabuild>
 19  </ditabuilds>
 20  ')
 21  columns
 22    mount  varchar2(100) path './@mount',
 23    locale varchar2(100) PATH './@locale',
 24    tail      varchar2(100) PATH './@tail',
 25    hash      varchar2(100) PATH './@hash'
 26  );

no rows selected


However, i got no output which is not i expected. i am expecting output like this:
123          323
en_us        en_us
abc          hij
45678        65678


any idea? thanks!

[Updated on: Wed, 29 July 2009 17:19]

Report message to a moderator

Re: how do i filter out the node which has attribute value equal empty [message #415988 is a reply to message #415935] Thu, 30 July 2009 01:29 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
I don't understand your result from your data and what you say and the query your gave. It seems inconsistent for me.

Quote:
i am trying to filter out the ditabuild which has child node ditabuildoutput and its basename attributes is empty

Quote:
$i/ditabuildoutput/@basename!="")

Empty or not?

What happens if a "ditabuild" contains both "ditabuildoutput" with empty and not empty basename?

Assuming you want "ditabuild" parmaters when it contains at least one "ditabuildoutput" with a non-empty basename.
I don't know how to do it in flower syntax but with SQL one:
SQL> with 
  2    data as (
  3      select xmltype('
  4        <ditabuilds>
  5          <ditabuild mount="123" locale="en_us" tail="abc" hash="45678">
  6            <ditabuildoutput basename="test11">value1</ditabuildoutput>
  7            <ditabuildoutput basename="test12">value2</ditabuildoutput>
  8          </ditabuild>
  9          <ditabuild mount="223" locale="en_us" tail="efg" hash="55678">
 10            <ditabuildoutput basename="">value21</ditabuildoutput>
 11          </ditabuild>
 12          <ditabuild mount="323" locale="en_us" tail="hij" hash="65678">
 13            <ditabuildoutput basename="test1">value31</ditabuildoutput>
 14            <ditabuildoutput basename="test2">value32</ditabuildoutput>
 15          </ditabuild>
 16         </ditabuilds>
 17       ') val
 18      from dual
 19    )
 20  select extractvalue(value(b),'/ditabuild/@mount') mount,
 21         extractvalue(value(b),'/ditabuild/@locale') locale,
 22         extractvalue(value(b),'/ditabuild/@tail') tail,
 23         extractvalue(value(b),'/ditabuild/@hash') hash
 24  from data a, 
 25       table(xmlsequence(extract(a.val,'/ditabuilds/ditabuild'))) b,
 26       table(xmlsequence(extract(b.column_value, '/ditabuild/ditabuildoutput'))) c
 27  group by extractvalue(value(b),'/ditabuild/@mount'),
 28           extractvalue(value(b),'/ditabuild/@locale'),
 29           extractvalue(value(b),'/ditabuild/@tail'),
 30           extractvalue(value(b),'/ditabuild/@hash')
 31  having max(nvl(extractvalue(value(c),'/ditabuildoutput/@basename'),' ')) != ' '
 32  /
MOUNT      LOCALE     TAIL       HASH
---------- ---------- ---------- ----------
323        en_us      hij        65678
123        en_us      abc        45678

2 rows selected.

Regards
Michel



Previous Topic: Java Stored Procedure, Reflection across Schemas
Next Topic: Conditional Formatting of ADF Table
Goto Forum:
  


Current Time: Sat Nov 23 06:39:51 CST 2024