/[classpath]/classpath/gnu/xml/transform/ValueOfNode.java
ViewVC logotype

Diff of /classpath/gnu/xml/transform/ValueOfNode.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by gnu_andrew, Sat Feb 12 14:26:02 2005 UTC revision 1.3 by dog, Thu Jun 30 22:09:07 2005 UTC
# Line 37  exception statement from your version. * Line 37  exception statement from your version. *
37    
38  package gnu.xml.transform;  package gnu.xml.transform;
39    
40    import java.util.Collection;
41    import java.util.Iterator;
42  import javax.xml.namespace.QName;  import javax.xml.namespace.QName;
43  import javax.xml.transform.TransformerException;  import javax.xml.transform.TransformerException;
44  import org.w3c.dom.Document;  import org.w3c.dom.Document;
# Line 56  final class ValueOfNode Line 58  final class ValueOfNode
58    final Expr select;    final Expr select;
59    final boolean disableOutputEscaping;    final boolean disableOutputEscaping;
60    
61    ValueOfNode(TemplateNode children, TemplateNode next, Expr select,    ValueOfNode(Expr select, boolean disableOutputEscaping)
               boolean disableOutputEscaping)  
62    {    {
     super(children, next);  
63      this.select = select;      this.select = select;
64      this.disableOutputEscaping = disableOutputEscaping;      this.disableOutputEscaping = disableOutputEscaping;
65    }    }
66    
67    TemplateNode clone(Stylesheet stylesheet)    TemplateNode clone(Stylesheet stylesheet)
68    {    {
69      return new ValueOfNode((children == null) ? null :      TemplateNode ret = new ValueOfNode(select.clone(stylesheet),
70                             children.clone(stylesheet),                                         disableOutputEscaping);
71                             (next == null) ? null :      if (children != null)
72                             next.clone(stylesheet),        {
73                             select.clone(stylesheet),          ret.children = children.clone(stylesheet);
74                             disableOutputEscaping);        }
75        if (next != null)
76          {
77            ret.next = next.clone(stylesheet);
78          }
79        return ret;
80    }    }
81    
82    void doApply(Stylesheet stylesheet, QName mode,    void doApply(Stylesheet stylesheet, QName mode,
# Line 80  final class ValueOfNode Line 85  final class ValueOfNode
85      throws TransformerException      throws TransformerException
86    {    {
87      Object ret = select.evaluate(context, pos, len);      Object ret = select.evaluate(context, pos, len);
88      String value = Expr._string(context, ret);      String value;
89      //System.err.println("value-of: "+context+" "+ select + " -> "+ value);      if (ret instanceof Collection)
90          {
91            StringBuffer buf = new StringBuffer();
92            for (Iterator i = ((Collection) ret).iterator(); i.hasNext(); )
93              {
94                Node node = (Node) i.next();
95                buf.append(Expr.stringValue(node));
96              }
97            value = buf.toString();
98          }
99        else
100          {
101            value = Expr._string(context, ret);
102          }
103        /*if (stylesheet.debug)
104          {
105            System.err.println("value-of: "+context+" "+ select + " -> "+ value);
106          }*/
107      if (value != null && value.length() > 0)      if (value != null && value.length() > 0)
108        {        {
109          Document doc = (parent instanceof Document) ?          Document doc = (parent instanceof Document) ?

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26