Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] How can I pass two filter in a transform method ??

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Kunal Chauhan <mail4ck AT gmail.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] How can I pass two filter in a transform method ??
  • Date: Fri, 4 May 2012 15:16:50 +0530

Hi

How can I pass two filter in a transform method ??

suppose my document is like below.

<product>

<main-prod id='01'>Stationary </main-prod>
...
...

<sub-prod category='01'>Pen</sub-prod>
<sub-prod category='01'>Pencil</sub-prod>

</product>


Here is my transform method


path is set as : product/*:*

public Nodes transform(Element subtree) {


Nodes results = XQueryUtil.xquery(subtree, ".[@id]");

for (int i=0; i < results.size(); i++) {


Element ele = (Element)((Node) results.get(i));

String id = ele.getAttributeValue("id");

Nodes results1 = XQueryUtil.xquery(subtree, ".[@id='"+id+"' or
@category='"+id+"']");

for (int j=0; j < results1.size(); j++) {

System.out.println("result: " + " : " +
results1.get(j).toXML());
}
}

return NONE;
}

};

Expected result is : <main-prod id='01'>Stationary </main-prod>
<sub-prod category='01'>Pen</sub-prod>
<sub-prod category='01'>Pencil</sub-prod>


Thanks,

--
*Kunal Chauhan*
mail4ck AT gmail.com
[+918655517141]
[+919904983614]




Archive powered by MHonArc 2.6.24.

Top of Page