<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2604" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=279461120-21032005>After
futher reviewing the Javadocs , I was using getValue() instead of using
getTextTrim(). The getValue returns <FONT size=3><FONT
color=#000000><FONT face="Times New Roman">"</FONT><FONT
face="Times New Roman">all text node descendants of this
element".</FONT></FONT></FONT></SPAN></FONT></DIV>
<DIV><FONT face="Times New Roman" color=#000000 size=3><SPAN
class=279461120-21032005></SPAN></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN
class=279461120-21032005>Thanks</SPAN></FONT></DIV>
<DIV><FONT face="Times New Roman" color=#000000 size=3><SPAN
class=279461120-21032005></SPAN></FONT> </DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
jdom-interest-bounces@jdom.org [mailto:jdom-interest-bounces@jdom.org] <B>On
Behalf Of </B>Sinkinson,Andrew [NCR]<BR><B>Sent:</B> March 21, 2005 2:23
PM<BR><B>To:</B> jdom-interest@jdom.org<BR><B>Subject:</B> RE: [jdom-interest]
Filter Content with xml:lang<BR><BR></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=755431719-21032005>Here
is the correct Sample XML:</SPAN></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2><SPAN class=755431719-21032005>
<P><FONT face=Arial size=2>Sample xml:</FONT> <BR><FONT face=Arial
color=#0000ff size=2><</FONT><FONT face=Arial color=#800000
size=2>Metadata</FONT><FONT face=Arial color=#ff0000 size=2> xmlns</FONT><FONT
face=Arial color=#0000ff size=2>="</FONT><FONT face=Arial color=#000000
size=2><A
href="http://www.samplens.com/">http://www.sampleNS.com</A></FONT><FONT
face=Arial color=#0000ff size=2>"></FONT>
<BR> <FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>RecordInfo</FONT><FONT
face=Arial color=#0000ff size=2>></FONT>
<BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT
face=Arial color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial color=#0000ff
size=2>="</FONT><FONT face=Arial color=#000000 size=2>en</FONT><FONT
face=Arial color=#0000ff size=2>"></FONT><FONT face=Arial color=#000000
size=2>StringEN</FONT><FONT face=Arial color=#0000ff size=2></</FONT><FONT
face=Arial color=#800000 size=2>Format</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT
face=Arial color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial color=#0000ff
size=2>="</FONT><FONT face=Arial color=#000000 size=2>fr</FONT><FONT
face=Arial color=#0000ff size=2>"></FONT><FONT face=Arial color=#000000
size=2>StringFR</FONT><FONT face=Arial color=#0000ff size=2></</FONT><FONT
face=Arial color=#800000 size=2>Format</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR><FONT face=Arial color=#0000ff
size=2>
<</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT face=Arial
color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial color=#0000ff
size=2>="</FONT><FONT face=Arial color=#000000 size=2>en</FONT><FONT
face=Arial color=#0000ff size=2>"></FONT><FONT face=Arial color=#000000
size=2>StringEN</FONT><FONT face=Arial color=#0000ff size=2></</FONT><FONT
face=Arial color=#800000 size=2>Format</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT
face=Arial color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial color=#0000ff
size=2>="</FONT><FONT face=Arial color=#000000 size=2>fr</FONT><FONT
face=Arial color=#0000ff size=2>"></FONT><FONT face=Arial color=#000000
size=2>StringFR</FONT><FONT face=Arial color=#0000ff size=2></</FONT><FONT
face=Arial color=#800000 size=2>Format</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>FormatID</FONT><FONT
face=Arial color=#0000ff size=2>></FONT><FONT face=Arial color=#000000
size=2>4</FONT><FONT face=Arial color=#0000ff size=2></</FONT><FONT
face=Arial color=#800000 size=2>FormatID</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>test</FONT><FONT
face=Arial color=#0000ff size=2>></FONT> <BR><FONT face=Arial color=#0000ff
size=2>
<</FONT><FONT face=Arial color=#800000 size=2>subtest</FONT><FONT
face=Arial color=#0000ff size=2>></FONT><FONT face=Arial color=#000000
size=2>222</FONT><FONT face=Arial color=#0000ff size=2></</FONT><FONT
face=Arial color=#800000 size=2>subtest</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR><FONT face=Arial color=#0000ff
size=2>
</</FONT><FONT face=Arial color=#800000 size=2>test</FONT><FONT face=Arial
color=#0000ff size=2>></FONT>
<BR> <FONT face=Arial color=#0000ff
size=2></</FONT><FONT face=Arial color=#800000
size=2>RecordInfo</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR><FONT face=Arial color=#0000ff size=2></</FONT><FONT face=Arial
color=#800000 size=2>Metadata</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> </P></SPAN></FONT></DIV></FONT></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT
face=Tahoma size=2>-----Original Message-----<BR><B>From:</B>
jdom-interest-bounces@jdom.org [mailto:jdom-interest-bounces@jdom.org] <B>On
Behalf Of </B>Sinkinson,Andrew [NCR]<BR><B>Sent:</B> March 21, 2005 1:28
PM<BR><B>To:</B> jdom-interest@jdom.org<BR><B>Subject:</B> [jdom-interest]
Filter Content with xml:lang<BR><BR></FONT></DIV><!-- Converted from text/rtf format --><BR>
<P><FONT face=Arial size=2> Hi all,</FONT> </P>
<P><FONT face=Arial size=2> I am wondering what is the
best way to filter out the content of a complex document based on
xml:lang. Basically for each language I want to filter out all
elements that match given xml:lang attribute and those that do not have an
xml:lang attribute.</FONT></P>
<P><FONT face=Arial size=2>Sample xml:</FONT> <BR><FONT face=Arial
color=#0000ff size=2><</FONT><FONT face=Arial color=#800000
size=2>Metadata</FONT><FONT face=Arial color=#ff0000 size=2>
xmlns</FONT><FONT face=Arial color=#0000ff size=2>="</FONT><FONT face=Arial
color=#000000 size=2><A
href="http://www.sampleNS.com">http://www.sampleNS.com</A></FONT><FONT
face=Arial color=#0000ff size=2>"></FONT>
<BR> <FONT face=Arial
color=#0000ff size=2><</FONT><FONT face=Arial color=#800000
size=2>RecordInfo</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT
face=Arial color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial
color=#0000ff size=2>="</FONT><FONT face=Arial color=#000000
size=2>en</FONT><FONT face=Arial color=#0000ff size=2>"></FONT><FONT
face=Arial color=#000000 size=2>StringEN</FONT><FONT face=Arial
color=#0000ff size=2></</FONT><FONT face=Arial color=#800000
size=2>commonFormat</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT
face=Arial color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial
color=#0000ff size=2>="</FONT><FONT face=Arial color=#000000
size=2>fr</FONT><FONT face=Arial color=#0000ff size=2>"></FONT><FONT
face=Arial color=#000000 size=2>StringFR</FONT><FONT face=Arial
color=#0000ff size=2></</FONT><FONT face=Arial color=#800000
size=2>commonFormat</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR><FONT face=Arial color=#0000ff
size=2>
<</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT
face=Arial color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial
color=#0000ff size=2>="</FONT><FONT face=Arial color=#000000
size=2>en</FONT><FONT face=Arial color=#0000ff size=2>"></FONT><FONT
face=Arial color=#000000 size=2>StringEN</FONT><FONT face=Arial
color=#0000ff size=2></</FONT><FONT face=Arial color=#800000
size=2>commonFormat</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>Format</FONT><FONT
face=Arial color=#ff0000 size=2> xml:lang</FONT><FONT face=Arial
color=#0000ff size=2>="</FONT><FONT face=Arial color=#000000
size=2>fr</FONT><FONT face=Arial color=#0000ff size=2>"></FONT><FONT
face=Arial color=#000000 size=2>StringFR</FONT><FONT face=Arial
color=#0000ff size=2></</FONT><FONT face=Arial color=#800000
size=2>commonFormat</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000
size=2>commonFormatID</FONT><FONT face=Arial color=#0000ff
size=2>></FONT><FONT face=Arial color=#000000 size=2>4</FONT><FONT
face=Arial color=#0000ff size=2></</FONT><FONT face=Arial color=#800000
size=2>commonFormatID</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR>
<FONT face=Arial color=#0000ff
size=2><</FONT><FONT face=Arial color=#800000 size=2>test</FONT><FONT
face=Arial color=#0000ff size=2>></FONT> <BR><FONT face=Arial
color=#0000ff
size=2>
<</FONT><FONT face=Arial color=#800000 size=2>subtest</FONT><FONT
face=Arial color=#0000ff size=2>></FONT><FONT face=Arial color=#000000
size=2>222</FONT><FONT face=Arial color=#0000ff size=2></</FONT><FONT
face=Arial color=#800000 size=2>subtest</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> <BR><FONT face=Arial color=#0000ff
size=2>
</</FONT><FONT face=Arial color=#800000 size=2>test</FONT><FONT
face=Arial color=#0000ff size=2>></FONT>
<BR> <FONT face=Arial
color=#0000ff size=2></</FONT><FONT face=Arial color=#800000
size=2>RecordInfo</FONT><FONT face=Arial color=#0000ff size=2>></FONT>
<BR><FONT face=Arial color=#0000ff size=2></</FONT><FONT face=Arial
color=#800000 size=2>Metadata</FONT><FONT face=Arial color=#0000ff
size=2>></FONT> </P>
<P><FONT face=Arial color=#0000ff size=2>Here is the code that is almost
working accept that I when I get the value of the root element and</FONT>
<FONT face=Arial color=#800000 size=2>RecordInfo</FONT><FONT face=Arial
color=#0000ff size=2> it give me all the content.</FONT></P>
<P><FONT face=Arial color=#0000ff size=2>Any help would be greatly
appreciated. Thanks</FONT> </P>
<P><FONT face=Arial color=#0000ff size=2>
String[] sLang = {"en","fr"};</FONT> <BR><FONT face=Arial color=#0000ff
size=2> for (int t = 0; t <
sLang.length; t++) {</FONT> <BR><FONT face=Arial color=#0000ff
size=2>
Iterator itr = doc.getDescendants(new ElementFilter(myNS));</FONT>
<BR><FONT face=Arial color=#0000ff
size=2>
while (itr.hasNext()) {</FONT> <BR><FONT face=Arial color=#0000ff
size=2>
</FONT><BR><FONT face=Arial color=#0000ff
size=2>
Element oTemp = (Element) itr.next();</FONT> <BR><FONT face=Arial
color=#0000ff
size=2>
</FONT><BR><FONT face=Arial color=#0000ff
size=2>
if(oTemp.getAttribute("lang",xmlNS) != null){</FONT> <BR><FONT face=Arial
color=#0000ff
size=2>
String attr = oTemp.getAttribute("lang",xmlNS).getValue();</FONT> <BR><FONT
face=Arial color=#0000ff
size=2>
</FONT><BR><FONT face=Arial color=#0000ff
size=2>
if(attr.equalsIgnoreCase(sLang[t])){</FONT> <BR><FONT face=Arial
color=#0000ff
size=2>
System.out.println(oTemp.getValue());</FONT> <BR><FONT face=Arial
color=#0000ff
size=2>
}</FONT> <BR><FONT face=Arial color=#0000ff
size=2>
}</FONT> <BR><FONT face=Arial color=#0000ff
size=2>
else</FONT> <BR><FONT face=Arial color=#0000ff
size=2>
{</FONT> <BR><FONT face=Arial color=#0000ff
size=2>
System.out.println(oTemp.getValue());</FONT> <BR><FONT face=Arial
color=#0000ff
size=2>
}</FONT> <BR><FONT face=Arial color=#0000ff
size=2>
}</FONT> <BR><FONT face=Arial color=#0000ff
size=2> }</FONT>
</P></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>