Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore.
       * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant.
       * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5.
       * java/lang/Math.java: New override file.
       * java/lang/Character.java: Merged from Classpath.
       (start, end): Now 'int's.
       (canonicalName): New field.
       (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants.
       (UnicodeBlock): Added argument.
       (of): New overload.
       (forName): New method.
       Updated unicode blocks.
       (sets): Updated.
       * sources.am: Regenerated.
       * Makefile.in: Likewise.

From-SVN: r111942
This commit is contained in:
Mark Wielaard
2006-03-10 21:46:48 +00:00
parent 27079765d0
commit 8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
@@ -317,7 +317,7 @@ abstract class AbstractNumberNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("number");
buf.append('[');
buf.append("format=");
buf.append(format);
@@ -1,5 +1,5 @@
/* ApplyImportsNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,13 +54,9 @@ final class ApplyImportsNode
{
TemplateNode ret = new ApplyImportsNode();
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -71,15 +67,16 @@ final class ApplyImportsNode
{
TemplateNode t = stylesheet.getTemplate(mode, context, true);
if (t != null)
{
t.apply(stylesheet, mode, context, pos, len,
parent, nextSibling);
}
t.apply(stylesheet, mode, context, pos, len,
parent, nextSibling);
if (next != null)
{
next.apply(stylesheet, mode, context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode, context, pos, len,
parent, nextSibling);
}
public String toString()
{
return "apply-imports";
}
}
@@ -1,5 +1,5 @@
/* ApplyTemplatesNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -76,29 +76,21 @@ final class ApplyTemplatesNode
TemplateNode clone(Stylesheet stylesheet)
{
int len = sortKeys.size();
int len = sortKeys != null ? sortKeys.size() : 0;
List sortKeys2 = new ArrayList(len);
for (int i = 0; i < len; i++)
{
sortKeys2.add(((Key) sortKeys.get(i)).clone(stylesheet));
}
sortKeys2.add(((Key) sortKeys.get(i)).clone(stylesheet));
len = withParams.size();
List withParams2 = new ArrayList(len);
for (int i = 0; i < len; i++)
{
withParams2.add(((WithParam) withParams.get(i)).clone(stylesheet));
}
withParams2.add(((WithParam) withParams.get(i)).clone(stylesheet));
TemplateNode ret = new ApplyTemplatesNode(select.clone(stylesheet),
mode, sortKeys2, withParams2,
isDefault);
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -147,9 +139,7 @@ final class ApplyTemplatesNode
Collections.sort(nodes, new XSLComparator(sortKeys));
}
else
{
Collections.sort(nodes, documentOrderComparator);
}
Collections.sort(nodes, documentOrderComparator);
int l = nodes.size();
QName effectiveMode = isDefault ? mode : this.mode;
for (int i = 0; i < l; i++)
@@ -172,27 +162,21 @@ final class ApplyTemplatesNode
}
// apply-templates doesn't have processable children
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public boolean references(QName var)
{
if (select != null && select.references(var))
{
return true;
}
return true;
if (withParams != null)
{
for (Iterator i = withParams.iterator(); i.hasNext(); )
{
if (((WithParam) i.next()).references(var))
{
return true;
}
return true;
}
}
if (sortKeys != null)
@@ -200,9 +184,7 @@ final class ApplyTemplatesNode
for (Iterator i = sortKeys.iterator(); i.hasNext(); )
{
if (((SortKey) i.next()).references(var))
{
return true;
}
return true;
}
}
return super.references(var);
@@ -210,7 +192,7 @@ final class ApplyTemplatesNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("apply-templates");
buf.append('[');
boolean o = false;
if (select != null)
@@ -231,7 +231,7 @@ final class AttributeNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("attribute");
buf.append('[');
buf.append("name=");
buf.append(name);
@@ -1,5 +1,5 @@
/* CallTemplateNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -69,18 +69,12 @@ final class CallTemplateNode
int len = withParams.size();
List withParams2 = new ArrayList(len);
for (int i = 0; i < len; i++)
{
withParams2.add(((WithParam) withParams.get(i)).clone(stylesheet));
}
withParams2.add(((WithParam) withParams.get(i)).clone(stylesheet));
TemplateNode ret = new CallTemplateNode(name, withParams2);
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -89,52 +83,52 @@ final class CallTemplateNode
Node parent, Node nextSibling)
throws TransformerException
{
if (withParams != null)
{
// compute the parameter values
LinkedList values = new LinkedList();
for (Iterator i = withParams.iterator(); i.hasNext(); )
{
WithParam p = (WithParam) i.next();
Object value = p.getValue(stylesheet, mode, context, pos, len);
Object[] pair = new Object[2];
pair[0] = p.name;
pair[1] = value;
values.add(pair);
}
// push the parameter context
stylesheet.bindings.push(Bindings.WITH_PARAM);
// set the parameters
for (Iterator i = values.iterator(); i.hasNext(); )
{
Object[] pair = (Object[]) i.next();
QName name = (QName) pair[0];
Object value = pair[1];
stylesheet.bindings.set(name, value, Bindings.WITH_PARAM);
if (stylesheet.debug)
{
System.err.println("with-param: " + name + " = " + value);
}
}
}
TemplateNode t = stylesheet.getTemplate(mode, name);
if (t != null)
{
if (withParams != null)
{
// compute the parameter values
LinkedList values = new LinkedList();
for (Iterator i = withParams.iterator(); i.hasNext(); )
{
WithParam p = (WithParam) i.next();
if (t.hasParam(p.name)) // ignore parameters not specified
{
Object value = p.getValue(stylesheet, mode, context,
pos, len);
Object[] pair = new Object[2];
pair[0] = p.name;
pair[1] = value;
values.add(pair);
}
}
// push the parameter context
stylesheet.bindings.push(Bindings.WITH_PARAM);
// set the parameters
for (Iterator i = values.iterator(); i.hasNext(); )
{
Object[] pair = (Object[]) i.next();
QName name = (QName) pair[0];
Object value = pair[1];
stylesheet.bindings.set(name, value, Bindings.WITH_PARAM);
if (stylesheet.debug)
System.err.println("with-param: " + name + " = " + value);
}
}
t.apply(stylesheet, mode, context, pos, len,
parent, nextSibling);
}
if (withParams != null)
{
// pop the variable context
stylesheet.bindings.pop(Bindings.WITH_PARAM);
if (withParams != null)
{
// pop the variable context
stylesheet.bindings.pop(Bindings.WITH_PARAM);
}
}
// call-template doesn't have processable children
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
}
public boolean references(QName var)
@@ -144,9 +138,7 @@ final class CallTemplateNode
for (Iterator i = withParams.iterator(); i.hasNext(); )
{
if (((WithParam) i.next()).references(var))
{
return true;
}
return true;
}
}
return super.references(var);
@@ -154,7 +146,7 @@ final class CallTemplateNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("call-template");
buf.append('[');
buf.append("name=");
buf.append(name);
@@ -1,5 +1,5 @@
/* ChooseNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,13 +54,9 @@ final class ChooseNode
{
TemplateNode ret = new ChooseNode();
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -70,22 +66,18 @@ final class ChooseNode
throws TransformerException
{
if (children != null)
{
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("choose");
buf.append('[');
buf.append(']');
return buf.toString();
@@ -1,5 +1,5 @@
/* CommentNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -58,13 +58,9 @@ final class CommentNode
{
TemplateNode ret = new CommentNode();
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -90,27 +86,18 @@ final class CommentNode
Comment comment = doc.createComment(value);
// Insert into result tree
if (nextSibling != null)
{
parent.insertBefore(comment, nextSibling);
}
parent.insertBefore(comment, nextSibling);
else
{
parent.appendChild(comment);
}
parent.appendChild(comment);
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
buf.append('[');
buf.append(']');
return buf.toString();
return "comment";
}
}
@@ -1,5 +1,5 @@
/* CopyNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -65,13 +65,9 @@ final class CopyNode
{
TemplateNode ret = new CopyNode(uas);
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -102,44 +98,32 @@ final class CopyNode
{
NamedNodeMap attrs = parent.getAttributes();
if (attrs != null)
{
attrs.setNamedItemNS(copy);
}
attrs.setNamedItemNS(copy);
}
}
else
{
if (nextSibling != null)
{
parent.insertBefore(copy, nextSibling);
}
parent.insertBefore(copy, nextSibling);
else
{
parent.appendChild(copy);
}
parent.appendChild(copy);
}
}
if (uas != null)
{
StringTokenizer st = new StringTokenizer(uas, " ");
while (st.hasMoreTokens())
{
addAttributeSet(stylesheet, mode, context, pos, len,
copy, null, st.nextToken());
}
addAttributeSet(stylesheet, mode, context, pos, len,
copy, null, st.nextToken());
}
if (children != null)
{
children.apply(stylesheet, mode,
context, pos, len,
copy, null);
}
children.apply(stylesheet, mode,
context, pos, len,
copy, null);
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
void addAttributeSet(Stylesheet stylesheet, QName mode,
@@ -151,32 +135,31 @@ final class CopyNode
{
AttributeSet as = (AttributeSet) i.next();
if (!as.name.equals(attributeSet))
{
continue;
}
continue;
if (as.uas != null)
{
StringTokenizer st = new StringTokenizer(as.uas, " ");
while (st.hasMoreTokens())
{
addAttributeSet(stylesheet, mode, context, pos, len,
parent, nextSibling, st.nextToken());
}
addAttributeSet(stylesheet, mode, context, pos, len,
parent, nextSibling, st.nextToken());
}
if (as.children != null)
{
as.children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
as.children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
buf.append('[');
buf.append(']');
StringBuffer buf = new StringBuffer("copy");
if (uas != null)
{
buf.append('[');
buf.append("uas=");
buf.append(uas);
buf.append(']');
}
return buf.toString();
}
@@ -1,5 +1,5 @@
/* CopyOfNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -70,13 +70,9 @@ final class CopyOfNode
{
TemplateNode ret = new CopyOfNode(select.clone(stylesheet));
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -102,9 +98,7 @@ final class CopyOfNode
// Use document element
src = ((Document) src).getDocumentElement();
if (src == null)
{
continue;
}
continue;
nodeType = Node.ELEMENT_NODE;
}
else if (nodeType == Node.ATTRIBUTE_NODE)
@@ -128,20 +122,14 @@ final class CopyOfNode
{
NamedNodeMap attrs = parent.getAttributes();
if (attrs != null)
{
attrs.setNamedItemNS(node);
}
attrs.setNamedItemNS(node);
}
else
{
if (nextSibling != null)
{
parent.insertBefore(node, nextSibling);
}
parent.insertBefore(node, nextSibling);
else
{
parent.appendChild(node);
}
parent.appendChild(node);
}
}
}
@@ -152,36 +140,28 @@ final class CopyOfNode
{
Text textNode = doc.createTextNode(value);
if (nextSibling != null)
{
parent.insertBefore(textNode, nextSibling);
}
parent.insertBefore(textNode, nextSibling);
else
{
parent.appendChild(textNode);
}
parent.appendChild(textNode);
}
}
// copy-of doesn't process children
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public boolean references(QName var)
{
if (select != null && select.references(var))
{
return true;
}
return true;
return super.references(var);
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("copy-of");
buf.append('[');
buf.append("select=");
buf.append(select);
@@ -126,9 +126,7 @@ final class DocumentFunction
Object arg1 = values.get(0);
Object arg2 = values.get(1);
if (!(arg2 instanceof Collection))
{
throw new RuntimeException("second argument is not a node-set");
}
throw new RuntimeException("second argument is not a node-set");
Collection arg2ns = (Collection) arg2;
String base2 = arg2ns.isEmpty() ? null :
((Node) arg2ns.iterator().next()).getBaseURI();
@@ -166,9 +164,7 @@ final class DocumentFunction
Collection document(String uri, String base)
{
if ("".equals(uri) || uri == null)
{
uri = this.base.getBaseURI();
}
uri = this.base.getBaseURI();
// Get fragment
Expr fragment = null;
@@ -197,10 +193,10 @@ final class DocumentFunction
source = resolver.resolveDOM(null, base, uri);
}
Node node = source.getNode();
// Strip whitespace
TransformerImpl.strip(stylesheet, node);
if (fragment == null)
{
return Collections.singleton(node);
}
return Collections.singleton(node);
else
{
Object ret = fragment.evaluate(node, 1, 1);
@@ -216,9 +212,7 @@ final class DocumentFunction
{
String msg = "can't open " + uri;
if (base != null)
{
msg += " with base " + base;
}
msg += " with base " + base;
throw new RuntimeException(msg);
}
}
@@ -227,16 +221,12 @@ final class DocumentFunction
{
Stylesheet s = stylesheet;
if (context instanceof Stylesheet)
{
s = (Stylesheet) context;
}
s = (Stylesheet) context;
DocumentFunction f = new DocumentFunction(s, base);
int len = args.size();
List args2 = new ArrayList(len);
for (int i = 0; i < len; i++)
{
args2.add(((Expr) args.get(i)).clone(context));
}
args2.add(((Expr) args.get(i)).clone(context));
f.setArguments(args2);
return f;
}
@@ -246,9 +236,7 @@ final class DocumentFunction
for (Iterator i = args.iterator(); i.hasNext(); )
{
if (((Expr) i.next()).references(var))
{
return true;
}
return true;
}
return false;
}
@@ -1,5 +1,5 @@
/* ElementNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -238,7 +238,7 @@ final class ElementNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("element");
buf.append('[');
buf.append("name=");
if (namespace != null)
@@ -1,5 +1,5 @@
/* ForEachNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -70,19 +70,13 @@ final class ForEachNode
int len = sortKeys.size();
List sortKeys2 = new ArrayList(len);
for (int i = 0; i < len; i++)
{
sortKeys2.add(((Key) sortKeys.get(i)).clone(stylesheet));
}
sortKeys2.add(((Key) sortKeys.get(i)).clone(stylesheet));
TemplateNode ret = new ForEachNode(select.clone(stylesheet),
sortKeys2);
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -113,9 +107,7 @@ final class ForEachNode
Collections.sort(list, new XSLComparator(sortKeys));
}
else
{
Collections.sort(list, documentOrderComparator);
}
Collections.sort(list, documentOrderComparator);
// Perform children for each node
int l = list.size();
int p = 1;
@@ -132,27 +124,21 @@ final class ForEachNode
stylesheet.currentTemplate = saved;
}
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public boolean references(QName var)
{
if (select != null && select.references(var))
{
return true;
}
return true;
if (sortKeys != null)
{
for (Iterator i = sortKeys.iterator(); i.hasNext(); )
{
if (((SortKey) i.next()).references(var))
{
return true;
}
return true;
}
}
return super.references(var);
@@ -160,7 +146,7 @@ final class ForEachNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("for-each");
buf.append('[');
buf.append("select=");
buf.append(select);
+13 -23
View File
@@ -1,5 +1,5 @@
/* IfNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -62,19 +62,15 @@ final class IfNode
{
TemplateNode ret = new IfNode(test.clone(stylesheet));
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
void doApply(Stylesheet stylesheet, QName mode,
Node context, int pos, int len,
Node parent, Node nextSibling)
Node context, int pos, int len,
Node parent, Node nextSibling)
throws TransformerException
{
Object ret = test.evaluate(context, pos, len);
@@ -84,32 +80,26 @@ final class IfNode
if (success)
{
if (children != null)
{
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public boolean references(QName var)
{
if (test != null && test.references(var))
{
return true;
}
return true;
return super.references(var);
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("if");
buf.append('[');
buf.append("test=");
buf.append(test);
@@ -196,12 +196,7 @@ final class LiteralNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
buf.append('[');
buf.append("source=");
buf.append(source);
buf.append(']');
return buf.toString();
return source.toString();
}
}
@@ -92,5 +92,17 @@ final class MessageNode
if (next != null && !terminate)
next.apply(stylesheet, mode, context, pos, len, parent, nextSibling);
}
public String toString()
{
StringBuffer buf = new StringBuffer("message");
if (terminate)
{
buf.append('[');
buf.append("terminate");
buf.append(']');
}
return buf.toString();
}
}
@@ -1,5 +1,5 @@
/* OtherwiseNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -54,13 +54,9 @@ final class OtherwiseNode
{
TemplateNode ret = new OtherwiseNode();
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -70,25 +66,18 @@ final class OtherwiseNode
throws TransformerException
{
if (children != null)
{
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
buf.append('[');
buf.append(']');
return buf.toString();
return "otherwise";
}
}
@@ -1,5 +1,5 @@
/* ParameterNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -73,13 +73,9 @@ final class ParameterNode
select.clone(stylesheet),
type);
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
@@ -96,18 +92,14 @@ final class ParameterNode
{
stylesheet.bindings.set(name, value, type);
if (stylesheet.debug)
{
System.err.println(this + ": set to " + value);
}
System.err.println(this + ": set to " + value);
}
// variable and param don't process children as such
// all subsequent instructions are processed with that variable context
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
// pop the variable context
stylesheet.bindings.pop(type);
}
@@ -117,9 +109,7 @@ final class ParameterNode
throws TransformerException
{
if (select != null)
{
return select.evaluate(context, pos, len);
}
return select.evaluate(context, pos, len);
else if (children != null)
{
Document doc = (context instanceof Document) ? (Document) context :
@@ -129,17 +119,13 @@ final class ParameterNode
return Collections.singleton(fragment);
}
else
{
return null;
}
return null;
}
public boolean references(QName var)
{
if (select != null && select.references(var))
{
return true;
}
return true;
return super.references(var);
}
@@ -151,33 +137,18 @@ final class ParameterNode
boolean r1 = references(pn.name);
boolean r2 = pn.references(name);
if (r1 && r2)
{
throw new IllegalArgumentException("circular definitions");
}
throw new IllegalArgumentException("circular definitions");
if (r1)
{
return 1;
}
return 1;
if (r2)
{
return -1;
}
return -1;
}
return 0;
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
buf.append('[');
buf.append("name=");
buf.append(name);
if (select != null)
{
buf.append(",select=");
buf.append(select);
}
buf.append(",type=");
StringBuffer buf = new StringBuffer();
switch (type)
{
case Bindings.VARIABLE:
@@ -190,6 +161,14 @@ final class ParameterNode
buf.append("with-param");
break;
}
buf.append('[');
buf.append("name=");
buf.append(name);
if (select != null)
{
buf.append(",select=");
buf.append(select);
}
buf.append(']');
return buf.toString();
}
@@ -1,5 +1,5 @@
/* ProcessingInstructionNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -66,19 +66,15 @@ final class ProcessingInstructionNode
{
TemplateNode ret = new ProcessingInstructionNode(name);
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
void doApply(Stylesheet stylesheet, QName mode,
Node context, int pos, int len,
Node parent, Node nextSibling)
Node context, int pos, int len,
Node parent, Node nextSibling)
throws TransformerException
{
String data = null;
@@ -98,24 +94,18 @@ final class ProcessingInstructionNode
ProcessingInstruction pi = doc.createProcessingInstruction(name, data);
// Insert into result tree
if (nextSibling != null)
{
parent.insertBefore(pi, nextSibling);
}
parent.insertBefore(pi, nextSibling);
else
{
parent.appendChild(pi);
}
parent.appendChild(pi);
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("processing-instruction");
buf.append('[');
buf.append("name=");
buf.append(name);
@@ -408,7 +408,7 @@ class Stylesheet
{
if (debug)
System.err.println("getTemplate: mode="+mode+" context="+context);
Set candidates = new TreeSet();
Template selected = null;
for (Iterator j = templates.iterator(); j.hasNext(); )
{
Template t = (Template) j.next();
@@ -426,10 +426,21 @@ class Stylesheet
}
//System.err.println("\t"+context+" "+t+"="+isMatch);
if (isMatch)
candidates.add(t);
{
// Conflict resolution
// @see http://www.w3.org/TR/xslt#conflict
if (selected == null)
selected = t;
else
{
if (t.precedence < selected.precedence ||
t.priority < selected.priority)
continue;
selected = t;
}
}
}
//System.err.println("\tcandidates="+candidates);
if (candidates.isEmpty())
if (selected == null)
{
// Apply built-in template
// Current template is unchanged
@@ -451,32 +462,39 @@ class Stylesheet
return null;
}
}
else
{
Template t = (Template) candidates.iterator().next();
// Set current template
currentTemplate = t;
if (debug)
System.err.println("\ttemplate="+t+" context="+context);
return t.node;
}
// Set current template
currentTemplate = selected;
if (debug)
System.err.println("\ttemplate="+currentTemplate+" context="+context);
return currentTemplate.node;
}
TemplateNode getTemplate(QName mode, QName name)
throws TransformerException
{
Set candidates = new TreeSet();
Template selected = null;
for (Iterator j = templates.iterator(); j.hasNext(); )
{
Template t = (Template) j.next();
boolean isMatch = t.matches(name);
if (isMatch)
candidates.add(t);
{
// Conflict resolution
// @see http://www.w3.org/TR/xslt#conflict
if (selected == null)
selected = t;
else
{
if (t.precedence < selected.precedence ||
t.priority < selected.priority)
continue;
selected = t;
}
}
}
if (candidates.isEmpty())
if (selected == null)
return null;
Template t = (Template) candidates.iterator().next();
return t.node;
return selected.node;
}
/**
@@ -504,11 +522,9 @@ class Stylesheet
String p = getAttribute(attrs, "priority");
String mm = getAttribute(attrs, "mode");
QName mode = (mm == null) ? null : getQName(mm);
double priority = (p == null) ? Template.DEFAULT_PRIORITY :
Double.parseDouble(p);
Node children = node.getFirstChild();
return new Template(this, name, match, parse(children),
precedence, priority, mode);
precedence, p, mode);
}
/**
@@ -799,7 +815,7 @@ class Stylesheet
templates.add(new Template(this, null, new Root(),
parse(rootClone),
precedence,
Template.DEFAULT_PRIORITY,
null,
null));
}
else
@@ -1,5 +1,5 @@
/* Template.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -66,51 +66,77 @@ class Template
final double priority;
final int precedence;
final QName mode;
final boolean isAnyNode; // is the match simply "node()"?
Template(Stylesheet stylesheet,
QName name, Pattern match, TemplateNode node,
int precedence, double priority, QName mode)
int precedence, String priorityAttr, QName mode)
{
this.stylesheet = stylesheet;
this.name = name;
this.match = match;
this.node = node;
// adjust priority if necessary
// see XSLT section 5.5
Test test = getNodeTest(match);
if (test != null)
this.precedence = precedence;
this.mode = mode;
double p = DEFAULT_PRIORITY;
boolean a = false;
if (priorityAttr != null)
p = Double.parseDouble(priorityAttr);
else
{
if (test instanceof NameTest)
// adjust priority if necessary
// see XSLT section 5.5
if (match instanceof Selector)
{
NameTest nameTest = (NameTest) test;
if (nameTest.matchesAny() ||
nameTest.matchesAnyLocalName())
Selector selector = (Selector) match;
Test[] tests = selector.getTests();
if (tests.length > 0)
{
priority = -0.25d;
}
else
{
priority = 0.0d;
}
}
else
{
NodeTypeTest nodeTypeTest = (NodeTypeTest) test;
if (nodeTypeTest.getNodeType() ==
Node.PROCESSING_INSTRUCTION_NODE &&
nodeTypeTest.getData() != null)
{
priority = 0.0d;
}
else
{
priority = -0.5d;
Test test = tests[0];
if (test instanceof NameTest)
{
NameTest nameTest = (NameTest) test;
if (nameTest.matchesAny())
p = -0.25d;
else if (nameTest.matchesAnyLocalName())
p = -0.20d;
else
p = 0.0d;
}
else
{
NodeTypeTest nodeTypeTest = (NodeTypeTest) test;
if (nodeTypeTest.getNodeType() ==
Node.PROCESSING_INSTRUCTION_NODE &&
nodeTypeTest.getData() != null)
p = 0.0d;
else
p = -0.5d;
a = (nodeTypeTest.getNodeType() == 0);
}
// Add a small difference for predicates
if (tests.length > 1)
p += ((double) tests.length - 1) * 0.001;
}
}
}
this.priority = p;
this.isAnyNode = a;
}
private Template(Stylesheet stylesheet,
QName name, Pattern match, TemplateNode node,
int precedence, double priority, QName mode, boolean isAnyNode)
{
this.stylesheet = stylesheet;
this.name = name;
this.match = match;
this.node = node;
this.precedence = precedence;
this.priority = priority;
this.mode = mode;
this.isAnyNode = isAnyNode;
}
Template clone(Stylesheet stylesheet)
@@ -124,7 +150,8 @@ class Template
(node == null) ? null : node.clone(stylesheet),
precedence,
priority,
mode);
mode,
isAnyNode);
}
public int compareTo(Object other)
@@ -134,29 +161,16 @@ class Template
Template t = (Template) other;
int d = t.precedence - precedence;
if (d != 0)
{
return d;
}
return d;
double d2 = t.priority - priority;
if (d2 != 0.0d)
{
return (int) Math.round(d2 * 1000.0d);
}
return (int) Math.round(d2 * 1000.0d);
}
return 0;
}
Test getNodeTest(Expr expr)
{
if (expr instanceof Selector)
{
Selector selector = (Selector) expr;
Test[] tests = selector.getTests();
if (tests.length > 0)
{
return tests[0];
}
}
return null;
}
@@ -164,13 +178,11 @@ class Template
{
if ((mode == null && this.mode != null) ||
(mode != null && !mode.equals(this.mode)))
{
return false;
}
return false;
if (match == null)
{
return false;
}
return false;
if (isAnyNode && node.getNodeType() == Node.DOCUMENT_NODE)
return false; // don't match document node
return match.matches(node);
}
@@ -186,9 +198,7 @@ class Template
ctx = ctx.parent)
{
if (ctx == stylesheet)
{
return true;
}
return true;
}
return false;
}
@@ -206,13 +216,12 @@ class Template
Node parent, Node nextSibling)
throws TransformerException
{
System.err.println("...applying " + toString() + " to " + context);
if (stylesheet.debug)
System.err.println("...applying " + toString() + " to " + context);
if (node != null)
{
node.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
node.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public String toString()
@@ -244,9 +253,7 @@ class Template
{
out.println(toString());
if (node != null)
{
node.list(1, out, true);
}
node.list(1, out, true);
}
}
@@ -64,9 +64,7 @@ abstract class TemplateNode
throws TransformerException
{
if (stylesheet.terminated)
{
return;
}
return;
if (Thread.currentThread().isInterrupted())
{
// Try to head off any infinite loops at the pass
@@ -91,13 +89,9 @@ abstract class TemplateNode
public boolean references(QName var)
{
if (children != null && children.references(var))
{
return true;
}
return true;
if (next != null && next.references(var))
{
return true;
}
return true;
return false;
}
@@ -107,18 +101,30 @@ abstract class TemplateNode
void list(int depth, PrintStream out, boolean listNext)
{
for (int i = 0; i < depth; i++)
{
out.print(" ");
}
out.print(" ");
out.println(toString());
if (children != null)
{
children.list(depth + 1, out, true);
}
children.list(depth + 1, out, true);
if (listNext && next != null)
next.list(depth, out, listNext);
}
/**
* Indicates whether the template for which this template node is the
* first node specifies the given parameter.
*/
boolean hasParam(QName name)
{
for (TemplateNode ctx = this; ctx != null; ctx = ctx.next)
{
next.list(depth, out, listNext);
if (ctx instanceof ParameterNode)
{
ParameterNode param = (ParameterNode) ctx;
if (param.type == Bindings.PARAM && param.name.equals(name))
return true;
}
}
return false;
}
}
@@ -1,5 +1,5 @@
/* TextNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -65,19 +65,15 @@ final class TextNode
{
TemplateNode ret = new TextNode(disableOutputEscaping);
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
void doApply(Stylesheet stylesheet, QName mode,
Node context, int pos, int len,
Node parent, Node nextSibling)
Node context, int pos, int len,
Node parent, Node nextSibling)
throws TransformerException
{
String value = "";
@@ -96,24 +92,28 @@ final class TextNode
}
Text text = doc.createTextNode(value);
if (disableOutputEscaping)
{
text.setUserData("disable-output-escaping", "yes", stylesheet);
}
text.setUserData("disable-output-escaping", "yes", stylesheet);
// Insert into result tree
if (nextSibling != null)
{
parent.insertBefore(text, nextSibling);
}
parent.insertBefore(text, nextSibling);
else
{
parent.appendChild(text);
}
parent.appendChild(text);
if (next != null)
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
public String toString()
{
StringBuffer buf = new StringBuffer("text");
if (disableOutputEscaping)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
buf.append('[');
buf.append("disable-output-escaping");
buf.append(']');
}
return buf.toString();
}
}
@@ -162,7 +162,7 @@ class TransformerImpl
}
// Make a copy of the source node, and strip it
context = context.cloneNode(true);
strip(context);
strip(stylesheet, context);
// XSLT transformation
try
{
@@ -321,7 +321,7 @@ class TransformerImpl
if (indent)
{
parent.normalize();
strip(parent);
strip(stylesheet, parent);
Document resultDoc = (parent instanceof Document) ?
(Document) parent :
parent.getOwnerDocument();
@@ -393,7 +393,7 @@ class TransformerImpl
/**
* Strip whitespace from the source tree.
*/
boolean strip(Node node)
static boolean strip(Stylesheet stylesheet, Node node)
throws TransformerConfigurationException
{
short nt = node.getNodeType();
@@ -444,7 +444,7 @@ class TransformerImpl
Node child = node.getFirstChild();
while (child != null)
{
boolean remove = strip(child);
boolean remove = strip(stylesheet, child);
Node next = child.getNextSibling();
if (remove)
node.removeChild(child);
@@ -691,7 +691,7 @@ class TransformerImpl
for (Iterator i = children.iterator(); i.hasNext(); )
{
ctx = (Node) i.next();
reindent(doc, ctx, offset + 1);
reindent(doc, ctx, offset);
}
}
else
@@ -709,9 +709,9 @@ class TransformerImpl
}
buf = new StringBuffer();
buf.append('\n');
ws = buf.toString();
for (int i = 0; i < offset; i++)
buf.append(INDENT_WHITESPACE);
ws = buf.toString();
node.appendChild(doc.createTextNode(ws));
}
}
@@ -126,7 +126,7 @@ final class ValueOfNode
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("value-of");
buf.append('[');
buf.append("select=");
buf.append(select);
@@ -1,5 +1,5 @@
/* WhenNode.java --
Copyright (C) 2004 Free Software Foundation, Inc.
Copyright (C) 2004,2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -62,19 +62,15 @@ final class WhenNode
{
TemplateNode ret = new WhenNode(test.clone(stylesheet));
if (children != null)
{
ret.children = children.clone(stylesheet);
}
ret.children = children.clone(stylesheet);
if (next != null)
{
ret.next = next.clone(stylesheet);
}
ret.next = next.clone(stylesheet);
return ret;
}
void doApply(Stylesheet stylesheet, QName mode,
Node context, int pos, int len,
Node parent, Node nextSibling)
Node context, int pos, int len,
Node parent, Node nextSibling)
throws TransformerException
{
Object ret = test.evaluate(context, pos, len);
@@ -84,35 +80,29 @@ final class WhenNode
if (success)
{
if (children != null)
{
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
children.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
else
{
if (next != null)
{
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
next.apply(stylesheet, mode,
context, pos, len,
parent, nextSibling);
}
}
public boolean references(QName var)
{
if (test != null && test.references(var))
{
return true;
}
return true;
return super.references(var);
}
public String toString()
{
StringBuffer buf = new StringBuffer(getClass().getName());
StringBuffer buf = new StringBuffer("when");
buf.append('[');
buf.append("test=");
buf.append(test);