morten 01/09/20 07:55:42
Modified: java/src/org/apache/xalan/xsltc/compiler VariableBase.java
WithParam.java
java/src/org/apache/xalan/xsltc/runtime BasisLibrary.java
Log:
Added escaping of special characters in parameter names when passed to a
template using <xsl:with param/>.
PR: bugzilla 3324
Obtained from: n/a
Submitted by: [EMAIL PROTECTED]
Reviewed by: [EMAIL PROTECTED]
Revision Changes Path
1.5 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableBase.java
Index: VariableBase.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/VariableBase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- VariableBase.java 2001/09/17 08:20:54 1.4
+++ VariableBase.java 2001/09/20 14:55:42 1.5
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: VariableBase.java,v 1.4 2001/09/17 08:20:54 morten Exp $
+ * @(#)$Id: VariableBase.java,v 1.5 2001/09/20 14:55:42 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -194,7 +194,7 @@
return _variable;
}
- private static String replace(String base, char c, String str) {
+ public static String replace(String base, char c, String str) {
final int len = base.length() - 1;
int pos;
while ((pos = base.indexOf(c)) > -1) {
1.6 +9 -5
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/WithParam.java
Index: WithParam.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/WithParam.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WithParam.java 2001/07/31 09:11:51 1.5
+++ WithParam.java 2001/09/20 14:55:42 1.6
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: WithParam.java,v 1.5 2001/07/31 09:11:51 morten Exp $
+ * @(#)$Id: WithParam.java,v 1.6 2001/09/20 14:55:42 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -149,6 +149,13 @@
}
}
+ private String escapeName(QName qname) {
+ String local = qname.getLocalPart();
+ local = Variable.replace(local, '.', "$dot$");
+ local = Variable.replace(local, '-', "$dash$");
+ return(local);
+ }
+
/**
* This code generates a sequence of bytecodes that call the
* addParameter() method in AbstractTranslet. The method call will add
@@ -159,10 +166,7 @@
final InstructionList il = methodGen.getInstructionList();
// Make name acceptable for use as field name in class
- // TODO: convert to escape sequence like $dot$ and $dash$
- String name = _name.getLocalPart(); // TODO: namespace ?
- name = name.replace('.', '_');
- name = name.replace('-', '_');
+ String name = escapeName(_name);
// Load reference to the translet (method is in AbstractTranslet)
il.append(classGen.loadTranslet());
1.15 +2 -2
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
Index: BasisLibrary.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- BasisLibrary.java 2001/09/20 14:25:45 1.14
+++ BasisLibrary.java 2001/09/20 14:55:42 1.15
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: BasisLibrary.java,v 1.14 2001/09/20 14:25:45 morten Exp $
+ * @(#)$Id: BasisLibrary.java,v 1.15 2001/09/20 14:55:42 morten Exp $
*
* The Apache Software License, Version 1.1
*
@@ -867,7 +867,7 @@
return(dom.getIterator());
}
else {
- runTimeTypeError("reference", "node-set");
+ runTimeTypeError("reference", obj.getClass().getName());
return null;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]