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
+ * [EMAIL PROTECTED] #NamespaceHelper(String, String, Document)} constructor
or created
+ * using the [EMAIL PROTECTED] #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/>
+ * <?xml version="1.0"><br/>
+ * <svg:svg xmlns:svg="http://www.w3.org/2000/svg"><br/>
+ * </svg:svg>
+ * </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><prefix:text/><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><prefix:text>Hello World!</prefix:text></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>
<!--