You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2003/10/06 18:35:37 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/xml/xlink ExtendedXLinkPipe.java
stefano 2003/10/06 09:35:37
Modified: src/java/org/apache/cocoon/xml/xlink ExtendedXLinkPipe.java
Log:
applying patch 20298
CVS: ----------------------------------------------------------------------
CVS: PR:
CVS: If this change addresses a PR in the problem report tracking
CVS: database, then enter the PR number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system, such as NCSA,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to Apache by someone else; i.e.,
CVS: they sent us a patch or a new module, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.
Revision Changes Path
1.5 +122 -50 cocoon-2.1/src/java/org/apache/cocoon/xml/xlink/ExtendedXLinkPipe.java
Index: ExtendedXLinkPipe.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/xml/xlink/ExtendedXLinkPipe.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExtendedXLinkPipe.java 24 Sep 2003 21:26:51 -0000 1.4
+++ ExtendedXLinkPipe.java 6 Oct 2003 16:35:37 -0000 1.5
@@ -50,14 +50,15 @@
*/
package org.apache.cocoon.xml.xlink;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
/**
* This class extends the XLink semantic capabilities to understand those
* elements that are have default linking semantics associated.
@@ -72,7 +73,7 @@
* be a way to remove this, that will be a happy day for XML and for Cocoon too.</p>
*
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
- * @author <a href="mailto:torstenknodt@datas-world.de">Torsten Knodt</a>
+ * @author <a href="mailto:tk-cocoon@datas-world.de">Torsten Knodt</a>
* @version CVS $Id$
*/
public abstract class ExtendedXLinkPipe extends XLinkPipe {
@@ -80,74 +81,145 @@
protected static Set arrayToSet(Object[] array) {
final Set set = new HashSet(array.length);
- for (int i = 0; i<array.length; i++)
+ for (int i = 0; i < array.length; i++)
set.add(array[i]);
return set;
}
-
+
private final Map MAP = new HashMap() {
{
- put("", arrayToSet(new String[] {
- "about", "action", "background", "data", "discuri", "href",
- "longdesc", "src"
- }));
- put("http://www.w3.org/1999/xhtml", arrayToSet(new String[] {
- "action", "background", "data", "href", "longdesc", "src"
- }));
- put("http://www.w3.org/2002/01/P3Pv1",
- arrayToSet(new String[]{ "about",
- "discuri" }));
+ put(
+ "",
+ arrayToSet(
+ new String[] {
+ "about",
+ "action",
+ "background",
+ "data",
+ "discuri",
+ "href",
+ "longdesc",
+ "onenterforward",
+ "onenterbackward",
+ "ontimer",
+ "onpick",
+ "src" }));
+ put(
+ "http://www.w3.org/1999/xhtml",
+ arrayToSet(
+ new String[] {
+ "action",
+ "background",
+ "data",
+ "href",
+ "longdesc",
+ "src" }));
+ put(
+ "http://www.w3.org/2001/XInclude",
+ arrayToSet(new String[] { "href" }));
+ put(
+ "http://www.wapforum.org/2001/wml",
+ arrayToSet(
+ new String[] {
+ "onenterforward",
+ "onenterbackward",
+ "ontimer",
+ "href",
+ "onpick",
+ "src" }));
+ put(
+ "http://www.w3.org/2002/01/P3Pv1",
+ arrayToSet(
+ new String[] { "about", "discuri", "src", "service" }));
}
};
private int attrIndex = -1;
- public void startElement(String uri, final String name, final String raw,
- final Attributes attr) throws SAXException {
- final Set attrList = (Set) MAP.get((uri==null) ? "" : uri);
-
- if (attrList!=null) {
- for (int i = 0; i<attr.getLength(); i++)
- if (attr.getURI(i).equals("") &&
- attrList.contains(attr.getLocalName(i))) {
+ public void startElement(
+ String uri,
+ final String name,
+ final String raw,
+ final Attributes attr)
+ throws SAXException {
+ final Set attrList = (Set) MAP.get((uri == null) ? "" : uri);
+
+ if (attrList != null) {
+ for (int i = attrIndex + 1; i < attr.getLength(); i++)
+ if (attr.getURI(i).equals("")
+ && attrList.contains(attr.getLocalName(i))) {
+
final String att = attr.getValue(i);
- if (att!=null) {
- final String str = ": URI="+uri+" NAME="+name+" RAW="+
- raw+" ATT="+attr.getLocalName(i)+
- " NS="+uri+" VALUE="+att;
-
- if (attrIndex!=-1) {
- getLogger().warn("Possible internal error"+str);
- }
- getLogger().debug("Transforming to XLink"+str);
+ if (att != null) {
+ final String str =
+ ": URI="
+ + uri
+ + " NAME="
+ + name
+ + " RAW="
+ + raw
+ + " ATT="
+ + attr.getLocalName(i)
+ + " NS="
+ + uri
+ + " VALUE="
+ + att;
+
+ if (getLogger().isDebugEnabled())
+ getLogger().debug("Transforming to XLink" + str);
+
attrIndex = i;
- simpleLink(att, null, null, null, null, null, uri,
- name, raw, attr);
+
+ simpleLink(
+ att,
+ null,
+ null,
+ null,
+ null,
+ null,
+ uri,
+ name,
+ raw,
+ attr);
+
return;
}
}
+ attrIndex = -1;
}
super.startElement(uri, name, raw, attr);
}
- public void simpleLink(final String href, final String role,
- final String arcrole, final String title,
- final String show, final String actuate,
- final String uri, final String name,
- final String raw,
- final Attributes attr) throws SAXException {
- if (attrIndex!=-1) {
- AttributesImpl newattr = new AttributesImpl(attr);
-
+ public void simpleLink(
+ final String href,
+ final String role,
+ final String arcrole,
+ final String title,
+ final String show,
+ final String actuate,
+ final String uri,
+ final String name,
+ final String raw,
+ final Attributes attr)
+ throws SAXException {
+ if (attrIndex != -1) {
+ final AttributesImpl newattr = new AttributesImpl(attr);
newattr.setValue(attrIndex, href);
- attrIndex = -1;
- super.startElement(uri, name, raw, newattr);
+ startElement(uri, name, raw, newattr);
} else {
- super.simpleLink(href, role, arcrole, title, show, actuate, uri,
- name, raw, attr);
+ super.simpleLink(
+ href,
+ role,
+ arcrole,
+ title,
+ show,
+ actuate,
+ uri,
+ name,
+ raw,
+ attr);
}
-
}
}