summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/xml/transform/Stylesheet.java
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2006-03-10 21:46:48 +0000
committerMark Wielaard <mark@gcc.gnu.org>2006-03-10 21:46:48 +0000
commit8aa540d2f783474d1d2e06f16744bf67b9c1facc (patch)
treeea38c56431c5d4528fb54254c3f8e50f517bede3 /libjava/classpath/gnu/xml/transform/Stylesheet.java
parent27079765d00123f8e53d0e1ef7f9d46559266e6d (diff)
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
Diffstat (limited to 'libjava/classpath/gnu/xml/transform/Stylesheet.java')
-rw-r--r--libjava/classpath/gnu/xml/transform/Stylesheet.java60
1 files changed, 38 insertions, 22 deletions
diff --git a/libjava/classpath/gnu/xml/transform/Stylesheet.java b/libjava/classpath/gnu/xml/transform/Stylesheet.java
index 51accaa3b9a..73b22969114 100644
--- a/libjava/classpath/gnu/xml/transform/Stylesheet.java
+++ b/libjava/classpath/gnu/xml/transform/Stylesheet.java
@@ -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