You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by th...@apache.org on 2005/11/30 12:15:16 UTC

svn commit: r349923 [2/2] - in /forrest/trunk: main/template-sites/v2/src/documentation/content/xdocs/ main/template-sites/v2/src/documentation/resources/themes/common/html/ whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/...

Added: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java
URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java?rev=349923&view=auto
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java (added)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java Wed Nov 30 03:14:46 2005
@@ -0,0 +1,212 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+/* $Id: NamespaceHelper.java 155269 2005-02-24 22:42:55Z andreas $  */
+
+package org.apache.lenya.xml;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+
+/**
+ * A NamespaceHelper object simplifies the creation of elements in a certain
+ * namespace. All elements are owned by a document that is passed to the
+ * {@link #NamespaceHelper(String, String, Document)} constructor or created
+ * using the {@link #NamespaceHelper(String, String, String)} constructor.
+ */
+public class NamespaceHelper {
+    private String namespaceUri;
+    private String prefix;
+    private Document document;
+
+    /**
+     * Creates a new instance of NamespaceHelper using an existing document. The
+     * document is not affected. If you omit the prefix, the default namespace is used.
+     * @param _document The document.
+     * @param _namespaceUri The namespace URI.
+     * @param _prefix The namespace prefix.
+     */
+    public NamespaceHelper(String _namespaceUri, String _prefix, Document _document) {
+        this.namespaceUri = _namespaceUri;
+        this.prefix = _prefix;
+        this.document = _document;
+    }
+
+    /**
+     * <p>
+     * Creates a new instance of NamespaceHelper. A new document is created
+     * using a document element in the given namespace with the given prefix.
+     * If you omit the prefix, the default namespace is used.
+     * </p>
+     * <p>
+     * NamespaceHelper("http://www.w3.org/2000/svg", "svg", "svg"):<br/>
+     * &lt;?xml version="1.0"&gt;<br/>
+     * &lt;svg:svg xmlns:svg="http://www.w3.org/2000/svg"&gt;<br/>
+     * &lt;/svg:svg&gt;
+     * </p>
+     * @param localName The local name of the document element.
+     * @param _namespaceUri The namespace URI.
+     * @param _prefix The namespace prefix.
+     * @throws ParserConfigurationException if an error occured
+     */
+    public NamespaceHelper(String _namespaceUri, String _prefix, String localName)
+        throws ParserConfigurationException {
+        this.namespaceUri = _namespaceUri;
+        this.prefix = _prefix;
+        setDocument(DocumentHelper.createDocument(getNamespaceURI(), getQualifiedName(localName),
+                null));
+    }
+
+    /**
+     * Sets the document of this NamespaceHelper.
+     * @param _document the document
+     */
+    protected void setDocument(Document _document) {
+        this.document = _document;
+    }
+
+    /**
+     * Returns the document that is used to create elements.
+     * @return A document object.
+     */
+    public Document getDocument() {
+        return this.document;
+    }
+
+    /**
+     * Returns the namespace URI of this NamespaceHelper.
+     * @return The namespace URI.
+     */
+    public String getNamespaceURI() {
+        return this.namespaceUri;
+    }
+
+    /**
+     * Returns the namespace prefix that is used to create elements.
+     * @return The namespace prefix.
+     */
+    public String getPrefix() {
+        return this.prefix;
+    }
+
+    /**
+     * Returns the qualified name for a local name using the prefix of this
+     * NamespaceHelper.
+     * @param localName The local name.
+     * @return The qualified name, i.e. prefix:localName.
+     */
+    public String getQualifiedName(String localName) {
+        if (getPrefix().equals("")) {
+            return localName;
+        }
+        return getPrefix() + ":" + localName;
+    }
+
+    /**
+     * <p>
+     * Creates an element within the namespace of this NamespaceHelper object with
+     * a given local name containing a text node.<br/>
+     * </p>
+     * <p>
+     * <code>createElement("text")</code>: <code>&lt;prefix:text/&gt;<code>.
+     * </p>
+     * @param localName The local name of the element.
+     * @return A new element.
+     */
+    public Element createElement(String localName) {
+        return getDocument().createElementNS(getNamespaceURI(), getQualifiedName(localName));
+    }
+
+    /**
+     * <p>
+     * Creates an element within the namespace of this NamespaceHelper object with
+     * a given local name containing a text node.
+     * </p>
+     * <p>
+     * <code>createElement("text", "Hello World!")</code>:
+     * <code>&lt;prefix:text&gt;Hello World!&lt;/prefix:text&gt;</code>.
+     * </p>
+     * @param localName The local name of the element.
+     * @param text The text for the text node inside the element.
+     * @return A new element containing a text node.
+     */
+    public Element createElement(String localName, String text) {
+        Element element = createElement(localName);
+        Text textNode = getDocument().createTextNode(text);
+        element.appendChild(textNode);
+
+        return element;
+    }
+
+    /**
+     * Returns all children of an element in the namespace
+     * of this NamespaceHelper.
+     * @param element The parent element.
+     * @return the children.
+     */
+    public Element[] getChildren(Element element) {
+        return DocumentHelper.getChildren(element, getNamespaceURI());
+    }
+
+    /**
+     * Returns all children of an element with a local name in the namespace
+     * of this NamespaceHelper.
+     * @param element The parent element.
+     * @param localName The local name of the children to return.
+     * @return the children.
+     */
+    public Element[] getChildren(Element element, String localName) {
+        return DocumentHelper.getChildren(element, getNamespaceURI(), localName);
+    }
+
+    /**
+     * Returns the first childr of an element with a local name in the namespace
+     * of this NamespaceHelper or <code>null</code> if none exists.
+     * @param element The parent element.
+     * @param localName The local name of the children to return.
+     * @return the first child.
+     */
+    public Element getFirstChild(Element element, String localName) {
+        return DocumentHelper.getFirstChild(element, getNamespaceURI(), localName);
+    }
+
+	/**
+	 * Returns the next siblings of an element with a local name in the namespace
+	 * of this NamespaceHelper or <code>null</code> if none exists.
+	 * @param element The parent element.
+	 * @param localName The local name of the children to return.
+	 * @return the next siblings.
+	 */
+	public Element[] getNextSiblings(Element element, String localName) {
+		return DocumentHelper.getNextSiblings(element, getNamespaceURI(), localName);
+	}
+
+    /**
+     * Returns the preceding siblings of an element with a local name in the namespace
+     * of this NamespaceHelper or <code>null</code> if none exists.
+     * @param element The parent element.
+     * @param localName The local name of the children to return.
+     * @return the preceding siblings.
+     */
+    public Element[] getPrecedingSiblings(Element element, String localName) {
+        return DocumentHelper.getPrecedingSiblings(element, getNamespaceURI(), localName);
+    }
+}

Propchange: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/output.xmap
URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/output.xmap?rev=349923&r1=349922&r2=349923&view=diff
==============================================================================
--- forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/output.xmap (original)
+++ forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.output.themer/output.xmap Wed Nov 30 03:14:46 2005
@@ -38,13 +38,15 @@
       </map:generator>
       <map:generator name="directory"
         src="org.apache.cocoon.generation.DirectoryGenerator" />
-      <!-- <map:generator name="structurerXsl"
-        src="org.apache.forrest.structurer.generation.StructurerXSLGenerator" /> -->
+      <!--<map:generator name="structurerXsl"
+        src="org.apache.forrest.structurer.generation.StructurerXSLGenerator" />
+      -->
     </map:generators>
     <map:transformers default="xslt">
       <map:transformer name="cinclude"
         src="org.apache.cocoon.transformation.CIncludeTransformer" />
-
+      <map:transformer name="dispatcher"
+        src="org.apache.forrest.dispatcher.transformation.DispatcherTransformer" />
       <map:transformer name="i18n"
         src="org.apache.cocoon.transformation.I18nTransformer">
         <catalogues default="contracts">
@@ -93,19 +95,31 @@
   </map:resources>
   <map:pipelines>
     <map:pipeline>
+      <map:match pattern="test.dispatcher">
+        <map:generate src="{lm:resolve.structurer.index-foo}" />
+        <map:transform type="dispatcher">
+          <map:parameter name="type" value="html" />
+        </map:transform>
+        <map:serialize />
+      </map:match>
       <map:match pattern="test.**">
+        <map:generate src="{lm:resolve.structurer.{1}}" />
+        <map:transform type="dispatcher">
+          <map:parameter name="type" value="html" />
+        </map:transform>
+        <map:serialize />
+        
+        <map:transform
+          src="resources/stylesheets/hooksMatcher-html.xsl" />
+        <!-- type="structurerXsl" -->
         <map:generate src="status.xml" />
-        <!-- <map:generate src="{lm:structurer.html.{1}}" type="structurerXsl"/> -->
         <map:transform src="resources/stylesheets/temp.xsl">
-          <map:parameter name="test" value="{lm:themes/images/{1}.gif}" />
+          <map:parameter name="test"
+            value="{lm:resolve.structurer.{1}}" />
         </map:transform>
-
         <map:serialize />
       </map:match>
     </map:pipeline>
-    <!-- DO NOT USE ANYMORE
-      FIXME: Finish rewriting move to lm ->  {lm:contract.{1}.{2}}del if finished-->
-    <!--FIXME:START-->
 
     <map:pipeline>
       <!--



Re: svn commit: r349923 [2/2] - in /forrest/trunk: ... whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/...

Posted by Thorsten Scherler <th...@apache.org>.
El vie, 02-12-2005 a las 14:27 +0000, Ross Gardler escribió:
> Thorsten Scherler wrote:
> >Also, in future please use 'svn copy' so that we
> >>retain the svn history.
> >>
> > 
> > 
> > yeah, sorry. I was offline and could not do it.
> 
> I was amazed to discover that even when offline you can do pretty much 
> everything with SVN. 

... but not copy from one rep to another because it needs to contact the
server AFAIK. ...or maybe I just used the wrong svn cp ... ...

> It seems to keep a local copy of every state.
> 
> Ross
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: svn commit: r349923 [2/2] - in /forrest/trunk: ... whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/...

Posted by Ross Gardler <rg...@apache.org>.
Thorsten Scherler wrote:
>Also, in future please use 'svn copy' so that we
>>retain the svn history.
>>
> 
> 
> yeah, sorry. I was offline and could not do it.

I was amazed to discover that even when offline you can do pretty much 
everything with SVN. It seems to keep a local copy of every state.

Ross

Re: svn commit: r349923 [2/2] - in /forrest/trunk: ... whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/...

Posted by Thorsten Scherler <th...@apache.org>.
El vie, 02-12-2005 a las 13:21 +1100, David Crossley escribió:
> Thorsten Scherler wrote:
> > David Crossley escribi??:
> > > Why org.apache.lenya.... ?
> > 
> > There are coming from there. ;-) I thought 2 classes are not worth
> > adding the whole lenya lib, so I copied them over.
> 
> But shouldn't they have o.a.forrest package names?
> 
> Otherwise we get a clash when we try to integrate
> Lenya later (depending how we do that integration).
> 

done.

> Also, in future please use 'svn copy' so that we
> retain the svn history.
> 

yeah, sorry. I was offline and could not do it.

salu2

> -David
> 
> > salu2
> > 
> > > -David
> > > 
> > > > Author: thorsten
> > > > Date: Wed Nov 30 03:14:46 2005
> > > > New Revision: 349923
> > > >
> > > > Added: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java
> > > > URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java?rev=349923&view=auto
> > > > ==============================================================================
> > -- 
> > thorsten
> > 
> > "Together we stand, divided we fall!" 
> > Hey you (Pink Floyd)
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: svn commit: r349923 [2/2] - in /forrest/trunk: ... whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/...

Posted by David Crossley <cr...@apache.org>.
Thorsten Scherler wrote:
> David Crossley escribi??:
> > Why org.apache.lenya.... ?
> 
> There are coming from there. ;-) I thought 2 classes are not worth
> adding the whole lenya lib, so I copied them over.

But shouldn't they have o.a.forrest package names?

Otherwise we get a clash when we try to integrate
Lenya later (depending how we do that integration).

Also, in future please use 'svn copy' so that we
retain the svn history.

-David

> salu2
> 
> > -David
> > 
> > > Author: thorsten
> > > Date: Wed Nov 30 03:14:46 2005
> > > New Revision: 349923
> > >
> > > Added: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java
> > > URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java?rev=349923&view=auto
> > > ==============================================================================
> -- 
> thorsten
> 
> "Together we stand, divided we fall!" 
> Hey you (Pink Floyd)

Re: svn commit: r349923 [2/2] - in /forrest/trunk: ... whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/...

Posted by Thorsten Scherler <th...@apache.org>.
El jue, 01-12-2005 a las 08:57 +1100, David Crossley escribió:
> Why org.apache.lenya.... ?
> 

There are coming from there. ;-) I thought 2 classes are not worth
adding the whole lenya lib, so I copied them over.

salu2

> -David
> 
> > Author: thorsten
> > Date: Wed Nov 30 03:14:46 2005
> > New Revision: 349923
> >
> > Added: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java
> > URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java?rev=349923&view=auto
> > ==============================================================================
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: svn commit: r349923 [2/2] - in /forrest/trunk: ... whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/...

Posted by David Crossley <cr...@apache.org>.
Why org.apache.lenya.... ?

-David

> Author: thorsten
> Date: Wed Nov 30 03:14:46 2005
> New Revision: 349923
>
> Added: forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java
> URL: http://svn.apache.org/viewcvs/forrest/trunk/whiteboard/plugins/org.apache.forrest.plugin.internal.structurer/src/java/org/apache/lenya/xml/NamespaceHelper.java?rev=349923&view=auto
> ==============================================================================