Notes:
Release Notes
OpenSHORE XML Merger 1.0
$Id: RELEASE.html,v 1.3 2004/05/20 22:30:37 heschulz Exp $
Copyright © 2004 Helge Schulz
-------------------------------------------------------------------------------
Introduction
Example
New in Version 1.0
Required Software
Usage
Command line options
Feedback and Bug Reporting
License
Credits
-------------------------------------------------------------------------------
Introduction
The OpenSHORE XML Merger (XMLM) merges XML tags from several different sources
(parsers and analysers) into one or more files. The program reads a very simple
file format (*.xmlm files) with one XML command per line. Such a line has the
format:
<file name> <begin line> <begin column> <end line> <end column> <tag> [<owner
tag>]
XMLM sorts these commands, removes duplicates, ensures correct tag structure
and generate XML files from listed files.
Example
If you try to analyse C-Code with embedded SQL, you have three different
sublanguages: C preprocessor, C and SQL:
/*
* example.h
*/
char * message;
/*
* example.sqc
*/
#include <stdio.h>
#define MESSAGE "Hello, world!"
void f() {
#include "example.h"
message = "Hello, world!";
printf("%s\n", message);
}
void g() {
#include "example.h"
message = MESSAGE;
printf("%s\n", message);
}
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR sqlprint;
int main(int argc, char * argv[]) {
f();
g();
EXEC SQL CONNECT TO test;
EXEC SQL CREATE TABLE foo (
id INTEGER NOT NULL,
message VARCHAR(20) NOT NULL,
PRIMARY KEY (id)
);
EXEC SQL COMMIT;
EXEC SQL INSERT INTO foo (id, message) VALUES (1, 'Hello, world!');
EXEC SQL COMMIT;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR message[20];
EXEC SQL END DECLARE SECTION;
EXEC SQL SELECT message INTO :message FROM foo WHERE id = 1;
EXEC SQL COMMIT;
printf("%s\n", message.arr);
EXEC SQL DROP TABLE foo;
EXEC SQL COMMIT;
EXEC SQL DISCONNECT;
return 0;
}
A complicated way to handle this, is to write one parser, who understand all
three languages. But often is it much simpler and more "reusable" to write
three different parser for each language, who over read the other ones. But how
to create one XML file with inserted markup for all languages?
XMLM solve this problem. Every sublanguage parser can write XML insert commands
in a file or append it to one file. Here are examples for output of the C
preprocessor parser,
example.sqc 5 1 5 19 <Include>
example.sqc 5 11 5 18 <Name>
example.sqc 7 1 7 32 <Macro Name="MESSAGE">
example.sqc 7 9 7 16 <Name>
example.sqc 10 4 10 24 <Include>
example.sqc 10 14 10 23 <Name>
example.sqc 17 4 17 24 <Include>
example.sqc 17 14 17 23 <Name>
the C parser
example.sqc 1 1 3 4 <Comment>
example.sqc 9 1 14 2 <Function Name="f">
example.sqc 9 6 9 7 <Name>
example.h 1 1 3 4 <Comment>
example.h 5 1 5 16 <Variable Name="f.message">
example.h 5 8 5 15 <Name> <Variable Name="f.message">
example.sqc 16 1 21 2 <Function Name="g">
example.sqc 16 6 16 7 <Name>
example.h 1 1 3 4 <Comment>
example.h 5 1 5 16 <Variable Name="g.message">
example.h 5 8 5 15 <Name> <Variable Name="g.message">
example.sqc 26 1 55 2 <Function Name="example.main">
example.sqc 26 5 26 9 <Name>
and the SQL parser.
example.sqc 30 4 30 29 <SqlConnect>
example.sqc 30 24 30 28 <Name>
example.sqc 31 4 36 6 <SqlCreateTable>
example.sqc 31 26 31 29 <Name>
example.sqc 39 4 39 71 <SqlInsert>
example.sqc 39 25 39 28 <Name>
example.sqc 45 4 45 64 <SqlSelect>
example.sqc 45 47 45 50 <Name>
example.sqc 50 4 50 28 <SqlDropTable>
example.sqc 50 24 50 27 <Name>
example.sqc 53 4 53 24 <SqlDisconnect>
You get as result from XMLM the following XML files (with additional line
breaks marked with backslash for readability):
<?xml version="1.0" encoding="ISO-8859-1"?>
<Comment>/*
* example.h
*/</Comment>
<Variable Name="f.message" Hotspot="Multiple"> \
<Variable Name="g.message" Hotspot="Multiple"> \
char * <Name>message</Name>; \
</Variable> \
</Variable>
<?xml version="1.0" encoding="ISO-8859-1"?>
<Comment>/*
* example.sqc
*/</Comment>
<Include>#include <<Name>stdio.h</Name>></Include>
<Macro Name="MESSAGE">#define <Name>MESSAGE</Name> "Hello, world!"</Macro>
<Function Name="f">void <Name>f</Name>() {
<Include>#include "<Name>example.h</Name>"</Include>
message = "Hello, world!";
printf("%s\n", message);
}</Function>
<Function Name="g">void <Name>g</Name>() {
<Include>#include "<Name>example.h</Name>"</Include>
message = MESSAGE;
printf("%s\n", message);
}</Function>
EXEC SQL INCLUDE sqlca;
EXEC SQL WHENEVER SQLERROR sqlprint;
<Function Name="example.main">int <Name>main</Name>(int argc, char * argv[])
{
f();
g();
<SqlConnect>EXEC SQL CONNECT TO <Name>test</Name>;</SqlConnect>
<SqlCreateTable>EXEC SQL CREATE TABLE <Name>foo</Name> (
id INTEGER NOT NULL,
message VARCHAR(20) NOT NULL,
PRIMARY KEY (id)
);</SqlCreateTable>
EXEC SQL COMMIT;
<SqlInsert>EXEC SQL INSERT INTO <Name>foo</Name> (id, message) VALUES (1,
'Hello, world!');</SqlInsert>
EXEC SQL COMMIT;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR message[20];
EXEC SQL END DECLARE SECTION;
<SqlSelect>EXEC SQL SELECT message INTO :message FROM <Name>foo</Name>
WHERE id = 1;</SqlSelect>
EXEC SQL COMMIT;
printf("%s\n", message.arr);
<SqlDropTable>EXEC SQL DROP TABLE <Name>foo</Name>;</SqlDropTable>
EXEC SQL COMMIT;
<SqlDisconnect>EXEC SQL DISCONNECT;</SqlDisconnect>
return 0;
}</Function>
New in Version 1.0
Release 1.0 is the first open source version of XML Merger from the
OpenSHORE.org project. XMLM was rewritten completely in Java. There was a non
open source version written in C, which was released in 2000.
Required Software
1. Java 2 runtime environment 1.3 or newer
Usage
You can use XMLM in three different ways:
1. As command line tool by calling
java -jar xmlm.jar -i <indir> -o <outdir> *.xmlm
2. As Ant task by
a. Add xmlm.jar to your Ant classpath
b. Add <taskdef resource="xmlm.tasks"/> to your build file header
c. Call XMLM inside one of your tasks with
<xmlm fromdir="src" todir="xml">
<fileset dir="xmlm" includes="*.xmlm"/>
</xmlm>
3. As library in your Java programs by
a. Add xmlm.jar to your classpath
b. Use the public methods of org.openshore.xmlm.MarkupMerger
MarkupMerger merger = new MarkupMerger();
merger.addCommand("file1", 1, 1, 5, 3, "<Comment>", "");
...
merger.mergeXML(indir, outdir);
To create XML files from the example files, please follow this steps:
Create XML files from command line:
1. Change into the examples directory
2. Execute XMLM with:
java -jar ../xmlm.jar -i src -o xml xmlm/*.xmlm
3. Look at the XML files in directory xml
Create XML files with Ant:
1. Add xmlm.jar to your Ant classpath
2. Change into the examples directory
3. Call Ant with:
ant -buildfile merge.xml
4. Look at the XML files in directory xml
Command line options
java -jar xmlm.jar [options] <xmlm file name>+
Options:
-i <input directory>
directory containing the source files to be augmented with markup
-o <output directory>
destination directory for augmented files
-dt <document type>
enclose document into document tag with given name
-mt <module type>
enclose document into object tag with given name
-ed <escaping depth>
number of entity escapes (default 2)
Examples:
__________________________________________________
|Option|Input|Output |
|______|_____|_____________________________________|
|-ed 0 |&<> |&<> |
|______|_____|_____________________________________|
|-ed 1 |&<> |&<> |
|______|_____|_____________________________________|
|-ed 2 |&<> |&amp;&lt;&gt; |
|______|_____|_____________________________________|
|-ed 3 |&<> |&amp;amp;&amp;lt;&amp;gt;|
|______|_____|_____________________________________|
-ts <tabulator size>
tabulator size (default 8)
-tr <tabulator replace spaces>
number of spaces to replace tabulator (0 = no replace, default 3)
-v
print version number
-xv <XML version number>
XML version number for output files (default 1.0)
-xe <XML encoding>
XML encoding for output files (default ISO-8859-1)
Feedback and Bug Reporting
Please send feedback, bug reports and patches to the following addresses:
* OpenSHORE mailing list for feedback and discussions
http://sourceforge.net/mail/?group_id=65882
list openshore-devel
* Bug tracking
http://sourceforge.net/tracker/?group_id=65882&atid=512595
category "xmlm"
* Patch queue
http://sourceforge.net/tracker/?group_id=65882&atid=512597
category "xmlm"
License
The OpenSHORE XML Merger source code and binaries are available under triple
license of GNU Public License (GPL), Lesser GNU Public License (LGPL) and the
OSI approved Common Public License (CPL).
Credits
Thanks to Ingo Hadan for helping writing the Java version, Denis Kuniß from
GrammarCraft for writing the C version in 2000 and Klaus Mayr for extending the
C version.
-------------------------------------------------------------------------------
SourceForge.net
Changes:
Change Log
OpenSHORE XML Merger 1.0
$Id: CHANGES.html,v 1.3 2004/05/20 22:30:37 heschulz Exp $
Copyright © 2004 Helge Schulz
-------------------------------------------------------------------------------
Version 1.0 released 2004-01-25
* Initial Java version
-------------------------------------------------------------------------------
SourceForge.net
Copyright © 2009 Geeknet, Inc. All rights reserved. Terms of Use