cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/sitemap ContentAggregator.java
Date Tue, 24 Apr 2001 22:26:52 GMT
giacomo     01/04/24 15:26:51

  Modified:    src/org/apache/cocoon/components/language/markup/sitemap/java
                        Tag: xml-cocoon2 sitemap.xsl
               src/org/apache/cocoon/sitemap Tag: xml-cocoon2
                        ContentAggregator.java
  Log:
  Added a prefix attribute to both map:aggregate and map:part to have a
  namespace prefix available.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.107 +3 -3      xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl
  
  Index: sitemap.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/sitemap/java/Attic/sitemap.xsl,v
  retrieving revision 1.1.2.106
  retrieving revision 1.1.2.107
  diff -u -r1.1.2.106 -r1.1.2.107
  --- sitemap.xsl	2001/04/24 20:21:27	1.1.2.106
  +++ sitemap.xsl	2001/04/24 22:26:48	1.1.2.107
  @@ -98,7 +98,7 @@
        *
        * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
        * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  -     * @version CVS $Id: sitemap.xsl,v 1.1.2.106 2001/04/24 20:21:27 giacomo Exp $
  +     * @version CVS $Id: sitemap.xsl,v 1.1.2.107 2001/04/24 22:26:48 giacomo Exp $
        */
       public class <xsl:value-of select="@file-name"/> extends AbstractSitemap {
         static final String LOCATION = "<xsl:value-of select="translate(@file-path, '/',
'.')"/>.<xsl:value-of select="@file-name"/>";
  @@ -976,7 +976,7 @@
           </xsl:with-param>
         </xsl:call-template>
       </xsl:if>
  -    <xsl:value-of select="$ca"/>.setRootElement("<xsl:value-of select="@element"/>",
"<xsl:value-of select="@ns"/>");
  +    <xsl:value-of select="$ca"/>.setRootElement("<xsl:value-of select="@element"/>",
"<xsl:value-of select="@ns"/>", "<xsl:value-of select="@prefix"/>");
       <xsl:apply-templates select="./map:part">
         <xsl:with-param name="ca"><xsl:value-of select="$ca"/></xsl:with-param>
       </xsl:apply-templates>
  @@ -992,7 +992,7 @@
           </xsl:with-param>
         </xsl:call-template>
       </xsl:if>
  -    <xsl:value-of select="$ca"/>.addPart(substitute(listOfMaps,"<xsl:value-of
select="@src"/>"), "<xsl:value-of select="@element"/>", "<xsl:value-of select="@ns"/>",
"<xsl:value-of select="@strip-root"/>");
  +    <xsl:value-of select="$ca"/>.addPart(substitute(listOfMaps,"<xsl:value-of
select="@src"/>"), "<xsl:value-of select="@element"/>", "<xsl:value-of select="@ns"/>",
"<xsl:value-of select="@strip-root"/>", "<xsl:value-of select="@prefix"/>");
     </xsl:template> <!-- match="map:part" -->
   
     <!-- collect parameter definitions -->
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.8   +33 -22    xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ContentAggregator.java
  
  Index: ContentAggregator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/sitemap/Attic/ContentAggregator.java,v
  retrieving revision 1.1.2.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- ContentAggregator.java	2001/04/24 20:21:26	1.1.2.7
  +++ ContentAggregator.java	2001/04/24 22:26:50	1.1.2.8
  @@ -41,7 +41,7 @@
   
   /**
    * @author <a href="mailto:giacomo@apache.org">Giacomo Pati</a>
  - * @version CVS $Id: ContentAggregator.java,v 1.1.2.7 2001/04/24 20:21:26 giacomo Exp $
  + * @version CVS $Id: ContentAggregator.java,v 1.1.2.8 2001/04/24 22:26:50 giacomo Exp $
    */
   
   public class ContentAggregator extends ContentHandlerWrapper
  @@ -55,6 +55,9 @@
       /** the namespace of the root element */
       protected String rootElementNS;
   
  +    /** the namespace prefix of the root element */
  +    protected String rootElementNSPrefix;
  +
       /** the parts */
       protected ArrayList parts = new ArrayList();
   
  @@ -114,11 +117,13 @@
           public String uri;
           public String element;
           public String namespace;
  +        public String prefix;
           boolean stripRootElement;
  -        public Part (String uri, String element, String namespace, String stripRoot) {
  +        public Part (String uri, String element, String namespace, String stripRoot, String
prefix) {
               this.uri = uri;
               this.element = element;
               this.namespace = namespace;
  +            this.prefix = prefix;
               if (stripRoot.equals("yes") || stripRoot.equals("true")) {
                   this.stripRootElement = true;
               } else {
  @@ -134,17 +139,19 @@
           getLogger().debug("ContentAggregator: generating aggregated content");
           collectParts();
           this.documentHandler.startDocument();
  -        this.startElem(this.rootElementNS, this.rootElement);
  +        this.startElem(this.rootElementNS, this.rootElementNSPrefix, this.rootElement);
           try {
               for (int i = 0; i < this.partEventPipelines.size(); i++) {
                   Part part = (Part)this.parts.get(i);
                   this.rootElementIndex = (part.stripRootElement ? 0 : -1);
                   String ns = part.namespace;
  +                String prefix = part.prefix;
                   if (ns.equals("")) {
                       ns = this.getNS();
  +                    prefix = "";
                   }
                   if (!part.element.equals("")) {
  -                    this.startElem(ns, part.element);
  +                    this.startElem(ns, prefix, part.element);
                   }
                   EventPipeline ep = (EventPipeline)this.partEventPipelines.get(i);
                   ((XMLProducer)ep).setConsumer(this);
  @@ -158,12 +165,12 @@
                       this.manager.release(ep);
                       this.environment.popURI();
                       if (!part.element.equals("")) {
  -                        this.endElem(part.element);
  +                        this.endElem(prefix, part.element);
                       }
                   }
               }
           } finally {
  -            this.endElem(this.rootElement);
  +            this.endElem(this.rootElementNSPrefix, this.rootElement);
               this.documentHandler.endDocument();
           }
           getLogger().debug("ContentAggregator: finished aggregating content");
  @@ -232,19 +239,17 @@
           this.sitemap = sitemap;
       }
   
  -    public void setRootElement(String element, String namespace) {
  +    public void setRootElement(String element, String namespace, String prefix) {
           this.rootElement = element;
  -        if (namespace == null) {
  -            this.rootElementNS = "";
  -        } else {
  -            this.rootElementNS = namespace;
  -        }
  -        getLogger().debug("ContentAggregator: root element='" + element + "' ns='" + namespace
+ "'");
  +        this.rootElementNS = namespace;
  +        this.rootElementNSPrefix = prefix;
  +        getLogger().debug("ContentAggregator: root element='" + element + "' ns='" + namespace
+ "' prefix='" + prefix + "'");
       }
  -    
  -    public void addPart(String uri, String element, String namespace, String stripRootElement)
{
  -        this.parts.add(new Part(uri, element, namespace, stripRootElement));
  -        getLogger().debug("ContentAggregator: part uri='" + uri + "' element='" + element
+ "' ns='" + namespace + "' stripRootElement='" + stripRootElement + "'");
  +
  +    public void addPart(String uri, String element, String namespace, String stripRootElement,
String prefix) {
  +        this.parts.add(new Part(uri, element, namespace, stripRootElement, prefix));
  +        getLogger().debug("ContentAggregator: part uri='" + uri + "' element='" + element
+ "' ns='" + namespace
  +                        + "' stripRootElement='" + stripRootElement + "' prefix='" + prefix
+ "'");
       }
   
       /**
  @@ -286,6 +291,7 @@
           this.parameters = null;
           this.rootElement = null;
           this.rootElementNS = null;
  +        this.rootElementNSPrefix = null;
           this.parts.clear();
           this.environment = null;
           this.partEventPipelines.clear();
  @@ -324,21 +330,26 @@
           return (String)currentNS.get(last);
       }
   
  -    private void startElem(String namespaceURI, String name) throws SAXException {
  +    private void startElem(String namespaceURI, String prefix, String name) throws SAXException
{
           this.pushNS(namespaceURI);
           AttributesImpl attrs = new AttributesImpl();
  +        String qname = name;
           if (!namespaceURI.equals("")) {
  -            this.documentHandler.startPrefixMapping("", namespaceURI);
  -            attrs.addAttribute("", "xmlns", "xmlns", "CDATA", namespaceURI);
  +            this.documentHandler.startPrefixMapping(prefix, namespaceURI);
  +            if (!prefix.equals("")) {
  +                attrs.addAttribute("", prefix, "xmlns:" + prefix, "CDATA", namespaceURI);
  +            } else {
  +                attrs.addAttribute("", "xmlns", "xmlns", "CDATA", namespaceURI);
  +            }
           }
           this.documentHandler.startElement(namespaceURI, name, name, attrs);
       }
   
  -    private void endElem(String name) throws SAXException {
  +    private void endElem(String prefix, String name) throws SAXException {
           String ns = this.popNS();
           this.documentHandler.endElement(ns, name, name);
           if (!ns.equals("")) {
  -            this.documentHandler.endPrefixMapping("");
  +            this.documentHandler.endPrefixMapping(prefix);
           }
       }
   
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message