Author: julien(a)jboss.com
Date: 2007-02-13 18:01:37 -0500 (Tue, 13 Feb 2007)
New Revision: 6257
Added:
trunk/tools/build.xml
trunk/tools/src/
trunk/tools/src/main/
trunk/tools/src/main/org/
trunk/tools/src/main/org/jboss/
trunk/tools/src/main/org/jboss/portal/
trunk/tools/src/main/org/jboss/portal/tools/
trunk/tools/src/main/org/jboss/portal/tools/dtd/
trunk/tools/src/main/org/jboss/portal/tools/dtd/DTDToDocbook.java
trunk/tools/src/main/org/jboss/portal/tools/dtd/Test.java
Log:
- added wutka DTD parser
- made a small tool which can convert a commented DTD into docbook (basic for now but
works)
Added: trunk/tools/build.xml
===================================================================
--- trunk/tools/build.xml (rev 0)
+++ trunk/tools/build.xml 2007-02-13 23:01:37 UTC (rev 6257)
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE project [
+ <!ENTITY buildmagic SYSTEM
"../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM
"../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
+ ]>
+
+<!-- $Id: build.xml 6206 2007-02-11 00:33:46Z julien(a)jboss.com $ -->
+
+<!--+======================================================================+-->
+<!--| JBoss Portal (The OpenSource Portal) Build File |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at
http://www.gnu.org. |-->
+<!--| |-->
+<!--| This file has been designed to work with the 'tools' module and
|-->
+<!--| Buildmagic extentions. |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss Portal">
+
+ <!--+====================================================================+-->
+ <!--| Setup |-->
+ <!--| |-->
+ <!--| Include the common build elements. |-->
+ <!--| |-->
+ <!--| This defines several different targets, properties and paths. |-->
+ <!--| It also sets up the basic extention tasks amoung other things. |-->
+ <!--+====================================================================+-->
+
+ &buildmagic;
+ &modules;
+ &defaults;
+ &tools;
+ &targets;
+
+ <!-- ================================================================== -->
+ <!-- Initialization -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Initialize the build system. Must depend on '_buildmagic:init'.
+ | Other targets should depend on 'init' or things will mysteriously fail.
+ -->
+
+ <target name="init" unless="init.disable"
depends="_buildmagic:init">
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Configuration |-->
+ <!--| |-->
+ <!--| This target is invoked by the Buildmagic initialization logic |-->
+ <!--| and should contain module specific configuration elements. |-->
+ <!--+====================================================================+-->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- Configure thirdparty libraries -->
+ &libraries;
+ <path id="library.classpath">
+ <path refid="wutka.dtdparser.classpath"/>
+ </path>
+
+ <!-- Configure modules -->
+ <call target="configure-modules"/>
+ <path id="dependentmodule.classpath">
+ </path>
+
+ <!--+=======================================+-->
+ <!--| Override any default properties here. |-->
+ <!--+=======================================+-->
+
+ <!-- Configure defaults & build tools -->
+ <call target="configure-defaults"/>
+ <call target="configure-tools"/>
+
+ <!--+=======================================+-->
+ <!--| Define module specific elements here. |-->
+ <!--+=======================================+-->
+ <property name="javadoc.private" value="true"/>
+ <property name="javadoc.protected" value="false"/>
+
+ </target>
+
+
+ <!--+====================================================================+-->
+ <!--| Compile |-->
+ <!--| |-->
+ <!--| This target should depend on other compile-* targets for each |-->
+ <!--| different type of compile that needs to be performed, short of |-->
+ <!--| documentation compiles. |-->
+ <!--+====================================================================+-->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="
+ _default:compile-classes,
+ _default:compile-etc,
+ _default:compile-resources">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Generate Output |-->
+ <!--| |-->
+ <!--| Generates the target output for this module. Target output is |-->
+ <!--| the output which is ment to be released or used by external |-->
+ <!--| modules. |-->
+ <!--+====================================================================+-->
+
+ <target name="output"
+ description="Generate all target output."
+ depends="compile">
+
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/portal-tools-lib.jar">
+ <fileset dir="${build.classes}">
+ </fileset>
+ </jar>
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Cleaning -->
+ <!-- ================================================================== -->
+
+ <!-- Clean up all build output -->
+ <target name="clean" depends="_default:clean">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Documents |-->
+ <!--| |-->
+ <!--| Generate all documentation for this module. |-->
+ <!--+====================================================================+-->
+
+ <target name="docs" depends="_default:docs">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Misc. -->
+ <!-- ================================================================== -->
+
+ <target name="main" depends="most"/>
+ <target name="all" depends="_default:all"/>
+ <target name="most" depends="_default:most"/>
+ <target name="help" depends="_default:help"/>
+
+ <target name="test" depends="init">
+ <java classname="org.jboss.portal.tools.dtd.Test">
+ <classpath>
+ <pathelement location="${build.classes}"/>
+ <path refid="library.classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+</project>
Property changes on: trunk/tools/build.xml
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/tools/src/main/org/jboss/portal/tools/dtd/DTDToDocbook.java
===================================================================
--- trunk/tools/src/main/org/jboss/portal/tools/dtd/DTDToDocbook.java
(rev 0)
+++ trunk/tools/src/main/org/jboss/portal/tools/dtd/DTDToDocbook.java 2007-02-13 23:01:37
UTC (rev 6257)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.tools.dtd;
+
+import com.wutka.dtd.DTDParser;
+import com.wutka.dtd.DTD;
+import com.wutka.dtd.DTDComment;
+import com.wutka.dtd.DTDElement;
+import com.wutka.dtd.DTDItem;
+import com.wutka.dtd.DTDContainer;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class DTDToDocbook
+{
+
+ /** . */
+ private DTD dtd;
+
+ public DTDToDocbook(DTD dtd)
+ {
+ this.dtd = dtd;
+ }
+
+ public void blah(PrintWriter writer) throws IOException
+ {
+ //
+ writer.println("<itemizedlist>");
+
+ Object[] items = dtd.getItems();
+ Object previous = null;
+ for (int i = 0;i < items.length;i++)
+ {
+ Object item = items[i];
+ if (item instanceof DTDElement)
+ {
+ DTDElement elt = (DTDElement)item;
+
+ writer.println("<listitem>");
+
+ //
+ writer.println("<para>");
+ writer.print("Element <![CDATA[");
+ elt.write(writer);
+ writer.println("]]>");
+ writer.write("</para>");
+
+ //
+ if (previous instanceof DTDComment)
+ {
+ DTDComment comment = (DTDComment)previous;
+
writer.println("<para><programlisting><![CDATA[");
+ writer.print(comment.getText().trim());
+ writer.println("]]></programlisting></para>");
+ }
+
+ writer.write("</listitem>");
+
+ //
+ }
+
+ //
+ previous = item;
+ }
+
+ //
+ writer.println("</itemizedlist>");
+ }
+
+}
Added: trunk/tools/src/main/org/jboss/portal/tools/dtd/Test.java
===================================================================
--- trunk/tools/src/main/org/jboss/portal/tools/dtd/Test.java (rev
0)
+++ trunk/tools/src/main/org/jboss/portal/tools/dtd/Test.java 2007-02-13 23:01:37 UTC (rev
6257)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.tools.dtd;
+
+import com.wutka.dtd.DTDParser;
+import com.wutka.dtd.DTD;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class Test
+{
+
+ public static void main(String[] args) throws IOException
+ {
+ blah("../core/src/resources/portal-core-sar/dtd/jboss-portlet_2_6.dtd",
"output/jboss-portlet_2_6.txt");
+ blah("../core/src/resources/portal-core-sar/dtd/jboss-app_2_6.dtd",
"output/jboss-app_2_6.txt");
+ blah("../core/src/resources/portal-core-sar/dtd/portal-object_2_6.dtd",
"output/portal-object_2_6.txt");
+
blah("../core/src/resources/portal-core-sar/dtd/portlet-instances_2_6.dtd",
"output/portlet-instances_2_6.txt");
+ }
+
+ private static void blah(String src, String dst) throws IOException
+ {
+ File f = new File(src);
+ DTDParser parser = new DTDParser(f);
+ DTD dtd = parser.parse();
+ DTDToDocbook toDocbook = new DTDToDocbook(dtd);
+ FileOutputStream out = new FileOutputStream(dst);
+ PrintWriter writer = new PrintWriter(new PrintStream(out), true);
+ toDocbook.blah(writer);
+ writer.close();
+ }
+}