get results bsed on a flag

View: New views
2 Messages — Rating Filter:   Alert me  

get results bsed on a flag

by kooboy :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i've an xml file like this
<list:controlled-term-list xmlns:list="http://test.org/schema/list" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:countries="http://test.org/schema/countries" xmlns:meddra="http://test.org/schema/meddra" xmlns:common="http://test.org/schema/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       
        <list:controlled-terms>
                <common:controlled-term xsi:type="countries:termType" visibility="PUBLIC">
                        <common:term-id>100000000315</common:term-id>
                        <common:term-name xml:lang="en" modified-by="secretariat" translation-status-code="CURRENT" modified-on="2007-08-20T14:41:09">Islamic Republic of Afghanistan</common:term-name>
                        <common:status modified-by="secretariat" status-code="CURRENT" modified-on="2007-08-20T14:41:09"/>
                       
                </common:controlled-term>
                <common:controlled-term xsi:type="countries:termType" visibility="PUBLIC">
                        <common:term-id>100000000316</common:term-id>
                        <common:term-name xml:lang="en" modified-by="secretariat" translation-status-code="CURRENT" modified-on="2007-08-20T14:41:09">Åland Islands</common:term-name>
                        <common:status modified-by="secretariat" status-code="CURRENT" modified-on="2007-08-20T14:41:09"/>
                        <countries:comments>These islands enjoy autonomous status under Finnish sovereignty. The special relationship between the European Union and the Åland Islands is set out in a protocol appended to the Treaty of Accession. (Moreover, this protocol confirms the special status of the Åland Islands under international law.) </countries:comments>
                </common:controlled-term>
               
        </list:controlled-terms>
</list:controlled-term-list>

in my java code I want to get the results(common:term-name,common:term-id)  based on <common:status status-code = current

my javacode is like this
SimpleNamespaceContext ns = new SimpleNamespaceContext();
         ns.addNamespace("list", "http://pharmacos.eudra.org/schema/list");
         ns.addNamespace("common", "http://pharmacos.eudra.org/schema/common");
       
         XPath xpath = new JDOMXPath( "/list:controlled-term-list/list:controlled-terms/common:controlled-term/common:status[@status-code='CURRENT']");
 
         SAXBuilder builder = new SAXBuilder();
 
         Document doc = builder.build( BASIC_XML );
       
         
         xpath.setNamespaceContext(ns);
         
         List results = xpath.selectNodes(doc);
         
         for(Object result:results){
        System.out.println(((Element)result).getValue());
       
         }
 
how do i do this can somebodyhelp me please.
Thanks

Re: get results bsed on a flag

by Baz-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/7/8 kooboy <gkdasari@...>:

>
> i've an xml file like this
> <list:controlled-term-list xmlns:list="http://test.org/schema/list"
> xmlns:fn="http://www.w3.org/2005/xpath-functions"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:countries="http://test.org/schema/countries"
> xmlns:meddra="http://test.org/schema/meddra"
> xmlns:common="http://test.org/schema/common"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
>        <list:controlled-terms>
>                <common:controlled-term xsi:type="countries:termType" visibility="PUBLIC">
>                        <common:term-id>100000000315</common:term-id>
>                        <common:term-name xml:lang="en" modified-by="secretariat"
> translation-status-code="CURRENT" modified-on="2007-08-20T14:41:09">Islamic
> Republic of Afghanistan</common:term-name>
>                        <common:status modified-by="secretariat" status-code="CURRENT"
> modified-on="2007-08-20T14:41:09"/>
>
>                </common:controlled-term>
>                <common:controlled-term xsi:type="countries:termType" visibility="PUBLIC">
>                        <common:term-id>100000000316</common:term-id>
>                        <common:term-name xml:lang="en" modified-by="secretariat"
> translation-status-code="CURRENT" modified-on="2007-08-20T14:41:09">Åland
> Islands</common:term-name>
>                        <common:status modified-by="secretariat" status-code="CURRENT"
> modified-on="2007-08-20T14:41:09"/>
>                        <countries:comments>These islands enjoy autonomous status under Finnish
> sovereignty. The special relationship between the European Union and the
> Åland Islands is set out in a protocol appended to the Treaty of Accession.
> (Moreover, this protocol confirms the special status of the Åland Islands
> under international law.) </countries:comments>
>                </common:controlled-term>
>
>        </list:controlled-terms>
> </list:controlled-term-list>
>
> in my java code I want to get the results(common:term-name,common:term-id)
> based on <common:status status-code = current

/list:controlled-term-list/list:controlled-terms/common:controlled-term[common:status/@status-code='CURRENT']/common:term-name|/list:controlled-term-list/list:controlled-terms/common:controlled-term[common:status/@status-code='CURRENT']/common:term-id

-Baz

>
> my javacode is like this
> SimpleNamespaceContext ns = new SimpleNamespaceContext();
>         ns.addNamespace("list", "http://pharmacos.eudra.org/schema/list");
>         ns.addNamespace("common",
> "http://pharmacos.eudra.org/schema/common");
>
>         XPath xpath = new JDOMXPath(
> "/list:controlled-term-list/list:controlled-terms/common:controlled-term/common:status[@status-code='CURRENT']");
>
>         SAXBuilder builder = new SAXBuilder();
>
>         Document doc = builder.build( BASIC_XML );
>
>
>         xpath.setNamespaceContext(ns);
>
>         List results = xpath.selectNodes(doc);
>
>         for(Object result:results){
>                 System.out.println(((Element)result).getValue());
>
>         }
>
> how do i do this can somebodyhelp me please.
> Thanks
> --
> View this message in context: http://www.nabble.com/get-results-bsed-on-a-flag-tp24395066p24395066.html
> Sent from the jaxen - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email