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...@locus.apache.org on 2000/09/25 16:48:26 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/xml/xlink XLinkConsumerBridge.java XLinkHandler.java

stefano     00/09/25 07:48:26

  Modified:    src/org/apache/cocoon/xml/xlink Tag: xml-cocoon2
                        XLinkConsumerBridge.java XLinkHandler.java
  Log:
  updated XLinkHandler API (now SAX2 complete)
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +94 -28    xml-cocoon/src/org/apache/cocoon/xml/xlink/Attic/XLinkConsumerBridge.java
  
  Index: XLinkConsumerBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/xml/xlink/Attic/XLinkConsumerBridge.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XLinkConsumerBridge.java	2000/09/05 17:25:37	1.1.2.1
  +++ XLinkConsumerBridge.java	2000/09/25 14:48:19	1.1.2.2
  @@ -10,6 +10,7 @@
   
   import org.xml.sax.SAXException;
   import org.xml.sax.Attributes;
  +import org.xml.sax.helpers.AttributesImpl;
   
   import org.apache.cocoon.xml.XMLConsumerBridge;
   
  @@ -23,7 +24,7 @@
    * NOTE: this is based on XLink W3C Candidate Recommendation 3 July 2000
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/09/05 17:25:37 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/09/25 14:48:19 $
    */
    
   public abstract class XLinkConsumerBridge extends XMLConsumerBridge implements XLinkHandler {
  @@ -70,7 +71,7 @@
   		        String title   = attr.getValue(XLINK_NAMESPACE_URI, XLINK_TITLE);
   		        String show    = attr.getValue(XLINK_NAMESPACE_URI, XLINK_SHOW);
   		        String actuate = attr.getValue(XLINK_NAMESPACE_URI, XLINK_ACTUATE);
  -		        this.simpleLink(href, role, arcrole, title, show, actuate);
  +		        this.simpleLink(href, role, arcrole, title, show, actuate, uri, name, raw, attr);
   		    } else if (type.equals(XLINK_TYPE_EXTENDED)) {
   		        if (this.extendedLinkElementName != null) {
   		            throw new SAXException("An XLink extended link cannot include another 'extended' element");
  @@ -83,7 +84,7 @@
   		        String title   = attr.getValue(XLINK_NAMESPACE_URI, XLINK_TITLE);
   		        this.extendedLinkElementName = name;
   		        this.extendedLinkElementURI = uri;
  -		        this.startExtendedLink(role, title);
  +		        this.startExtendedLink(role, title, uri, name, raw, attr);
   		    } else if (type.equals(XLINK_TYPE_LOCATOR)) {
                   if (this.extendedLinkElementName == null) {
   		            throw new SAXException("An XLink locator must be included into an 'extended' element");
  @@ -98,7 +99,7 @@
   		        String label   = attr.getValue(XLINK_NAMESPACE_URI, XLINK_LABEL);
   		        this.linkLocatorElementName = name;
   		        this.linkLocatorElementURI = uri;
  -		        this.startLocator(href, role, title, label);
  +		        this.startLocator(href, role, title, label, uri, name, raw, attr);
   		    } else if (type.equals(XLINK_TYPE_ARC)) {
                   if (this.extendedLinkElementName == null) {
   		            throw new SAXException("An XLink arc must be included into an 'extended' element");
  @@ -115,7 +116,7 @@
   		        String to      = attr.getValue(XLINK_NAMESPACE_URI, XLINK_TO);
   		        this.linkArcElementName = name;
   		        this.linkArcElementURI = uri;
  -		        this.startArc(arcrole, title, show, actuate, from, to);
  +		        this.startArc(arcrole, title, show, actuate, from, to, uri, name, raw, attr);
   		    } else if (type.equals(XLINK_TYPE_RESOURCE)) {
                   if (this.extendedLinkElementName == null) {
   		            throw new SAXException("An XLink resource must be included into an 'extended' element");
  @@ -123,14 +124,14 @@
   		        String role    = attr.getValue(XLINK_NAMESPACE_URI, XLINK_ROLE);
   		        String title   = attr.getValue(XLINK_NAMESPACE_URI, XLINK_TITLE);
   		        String label   = attr.getValue(XLINK_NAMESPACE_URI, XLINK_LABEL);
  -		        this.linkResource(role, title, label);
  +		        this.linkResource(role, title, label, uri, name, raw, attr);
   		    } else if (type.equals(XLINK_TYPE_TITLE)) {
                   if ((this.extendedLinkElementName == null) 
                     && (this.linkLocatorElementName == null) 
                     && (this.linkArcElementName == null)) {
   		            throw new SAXException("An XLink title must be included into an 'extended', 'locator' or 'arc' element");
   		        }
  -		        this.linkTitle();
  +		        this.linkTitle(uri, name, raw, attr);
   		    } else {
                   super.startElement(uri, name, raw, attr);
               }
  @@ -141,38 +142,103 @@
   	    if ((name.equals(this.extendedLinkElementName)) && (uri.equals(this.extendedLinkElementURI))) {
   	        this.extendedLinkElementName = null;
   	        this.extendedLinkElementURI = null;
  -	        this.endExtendedLink();
  +	        this.endExtendedLink(uri, name, raw);
   	    } else if ((name.equals(this.linkLocatorElementName)) && (uri.equals(this.linkLocatorElementURI))) {
   	        this.linkLocatorElementName = null;
   	        this.linkLocatorElementURI = null;
  -	        this.endLocator();
  +	        this.endLocator(uri, name, raw);
   	    } else if ((name.equals(this.linkArcElementName)) && (uri.equals(this.linkArcElementURI))) {
   	        this.linkArcElementName = null;
   	        this.linkArcElementURI = null;
  -	        this.endArc();
  +	        this.endArc(uri, name, raw);
   	    } else {
   	        super.endElement(uri, name, raw);
   	    }
   	}
   
  -    // XLinkHandler implementation
  +    // Default XLinkHandler implementation (defaults to copy over)
       
  -    public void simpleLink(String href, String role, String arcrole, String title, String show, String actuate) throws SAXException {}
  -    
  -    public void startExtendedLink(String role, String title) throws SAXException {}
  -    
  -    public void endExtendedLink() throws SAXException {}
  -    
  -    public void startLocator(String href, String role, String title, String label) throws SAXException {}
  -
  -    public void endLocator() throws SAXException {}
  -    
  -    public void startArc(String arcrole, String title, String show, String actuate, String from, String to) throws SAXException {}
  -    
  -    public void endArc() throws SAXException {}
  -
  -    public void linkResource(String role, String title, String label) throws SAXException {}
  -    
  -    public void linkTitle() throws SAXException {}
  +    public void simpleLink(String href, String role, String arcrole, String title, String show, String actuate, String uri, String name, String raw, Attributes attr) throws SAXException {
  +        AttributesImpl newattr = new AttributesImpl(attr);
  +        int hrefIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_HREF);
  +        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  +        int arcroleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ARCROLE);
  +        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  +        int showIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_SHOW);
  +        int actuateIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ACTUATE); 
  +        if (hrefIndex > -1) newattr.setValue(hrefIndex, href);
  +        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  +        if (arcroleIndex > -1) newattr.setValue(arcroleIndex, arcrole);
  +        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  +        if (showIndex > -1) newattr.setValue(showIndex, show);
  +        if (actuateIndex > -1) newattr.setValue(actuateIndex, actuate);
  +        super.startElement(uri, name, raw, newattr);
  +    }
  +
  +    public void startExtendedLink(String role, String title, String uri, String name, String raw, Attributes attr) throws SAXException {
  +        AttributesImpl newattr = new AttributesImpl(attr);
  +        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  +        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  +        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  +        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  +        super.startElement(uri, name, raw, newattr);
  +    }
  +    
  +    public void startLocator(String href, String role, String title, String label, String uri, String name, String raw, Attributes attr) throws SAXException {
  +        AttributesImpl newattr = new AttributesImpl(attr);
  +        int hrefIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_HREF);
  +        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  +        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  +        int labelIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_LABEL);
  +        if (hrefIndex > -1) newattr.setValue(hrefIndex, href);
  +        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  +        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  +        if (labelIndex > -1) newattr.setValue(labelIndex, label);
  +        super.startElement(uri, name, raw, newattr);
  +    }
  +
  +    public void startArc(String arcrole, String title, String show, String actuate, String from, String to, String uri, String name, String raw, Attributes attr) throws SAXException {
  +        AttributesImpl newattr = new AttributesImpl(attr);
  +        int arcroleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ARCROLE);
  +        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  +        int showIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_SHOW);
  +        int actuateIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ACTUATE); 
  +        int fromIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_FROM); 
  +        int toIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TO); 
  +        if (arcroleIndex > -1) newattr.setValue(arcroleIndex, arcrole);
  +        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  +        if (showIndex > -1) newattr.setValue(showIndex, show);
  +        if (actuateIndex > -1) newattr.setValue(actuateIndex, actuate);
  +        if (fromIndex > -1) newattr.setValue(actuateIndex, from);
  +        if (toIndex > -1) newattr.setValue(actuateIndex, to);
  +        super.startElement(uri, name, raw, newattr);
  +    }
  +    
  +    public void linkResource(String role, String title, String label, String uri, String name, String raw, Attributes attr) throws SAXException {
  +        AttributesImpl newattr = new AttributesImpl(attr);
  +        int roleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_ROLE);
  +        int titleIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_TITLE);
  +        int labelIndex = attr.getIndex(XLINK_NAMESPACE_URI, XLINK_LABEL);
  +        if (roleIndex > -1) newattr.setValue(roleIndex, role);
  +        if (titleIndex > -1) newattr.setValue(titleIndex, title);
  +        if (labelIndex > -1) newattr.setValue(labelIndex, label);
  +        super.startElement(uri, name, raw, newattr);
  +    }
  +    
  +    public void linkTitle(String uri, String name, String raw, Attributes attr) throws SAXException {
  +        super.startElement(uri, name, raw, attr);
  +    }
  +    
  +    public void endExtendedLink(String uri, String name, String raw) throws SAXException {
  +        super.endElement(uri, name, raw);
  +    }
  +    
  +    public void endLocator(String uri, String name, String raw) throws SAXException {
  +        super.endElement(uri, name, raw);
  +    }
  +    
  +    public void endArc(String uri, String name, String raw) throws SAXException {
  +        super.endElement(uri, name, raw);
  +    }
   }
   
  
  
  
  1.1.2.2   +11 -10    xml-cocoon/src/org/apache/cocoon/xml/xlink/Attic/XLinkHandler.java
  
  Index: XLinkHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/xml/xlink/Attic/XLinkHandler.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XLinkHandler.java	2000/08/23 22:44:30	1.1.2.1
  +++ XLinkHandler.java	2000/09/25 14:48:21	1.1.2.2
  @@ -8,6 +8,7 @@
   
   package org.apache.cocoon.xml.xlink;
   
  +import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
   /**
  @@ -15,27 +16,27 @@
    * event driven design patterns that SAX enforces.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/08/23 22:44:30 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/09/25 14:48:21 $
    */
   public interface XLinkHandler  {
       
  -    public void simpleLink(String href, String role, String arcrole, String title, String show, String actuate) throws SAXException;
  +    public void simpleLink(String href, String role, String arcrole, String title, String show, String actuate, String uri, String name, String raw, Attributes attr) throws SAXException;
       
  -    public void startExtendedLink(String role, String title) throws SAXException;
  +    public void startExtendedLink(String role, String title, String uri, String name, String raw, Attributes attr) throws SAXException;
       
  -    public void endExtendedLink() throws SAXException;
  +    public void endExtendedLink(String uri, String name, String raw) throws SAXException;
       
  -    public void startLocator(String href, String role, String title, String label) throws SAXException;
  +    public void startLocator(String href, String role, String title, String label, String uri, String name, String raw, Attributes attr) throws SAXException;
   
  -    public void endLocator() throws SAXException;
  +    public void endLocator(String uri, String name, String raw) throws SAXException;
       
  -    public void startArc(String arcrole, String title, String show, String actuate, String from, String to) throws SAXException;
  +    public void startArc(String arcrole, String title, String show, String actuate, String from, String to, String uri, String name, String raw, Attributes attr) throws SAXException;
       
  -    public void endArc() throws SAXException;
  +    public void endArc(String uri, String name, String raw) throws SAXException;
   
  -    public void linkResource(String role, String title, String label) throws SAXException;
  +    public void linkResource(String role, String title, String label, String uri, String name, String raw, Attributes attr) throws SAXException;
       
  -    public void linkTitle() throws SAXException;
  +    public void linkTitle(String uri, String name, String raw, Attributes attr) throws SAXException;
       
   }