01: /*
02: * Created on Dec 8, 2003
03: *
04: * To change the template for this generated file go to
05: * Window>Preferences>Java>Code Generation>Code and Comments
06: */
07: package org.xdev.base.xssl.text.xml;
08:
09: import java.util.HashMap;
10:
11: import org.jaxen.jdom.JDOMXPath;
12: import org.jdom.Attribute;
13: import org.jdom.Element;
14: import org.jdom.Text;
15:
16: /**
17: * @author AYegorov
18: *
19: * To change the template for this generated type comment go to
20: * Window>Preferences>Java>Code Generation>Code and Comments
21: */
22: public class XmlSearchElement extends AbstractXmlSearch {
23:
24: /**
25: * @param id
26: */
27: public XmlSearchElement(String id) {
28: super (id);
29: // TODO Auto-generated constructor stub
30: }
31:
32: /**
33: * @param id
34: * @param properties
35: */
36: public XmlSearchElement(String id, HashMap properties) {
37: super (id, properties);
38: // TODO Auto-generated constructor stub
39: }
40:
41: /* (non-Javadoc)
42: * @see org.xdev.base.transaction.xml.AbstractXmlSearch#searchXml(org.jaxen.jdom.JDOMXPath, org.jdom.Element)
43: */
44: protected Object searchXml(JDOMXPath xpath, Element elm)
45: throws Exception {
46: Object obj = xpath.selectSingleNode(elm);
47:
48: Object returnValue = null;
49:
50: if (this .getBooleanProperty("retain")) {
51: returnValue = obj;
52: } else if (obj instanceof Element) {
53: returnValue = ((Element) obj).getTextTrim();
54: } else if (obj instanceof Attribute) {
55: returnValue = ((Attribute) obj).getValue();
56: } else if (obj instanceof Text) {
57: returnValue = ((Text) obj).getTextTrim();
58: }
59:
60: return returnValue;
61: }
62:
63: }
|