Skip to content

Commit

Permalink
Added build properties
Browse files Browse the repository at this point in the history
Added XSL stylesheet to create RegXML XSD (Issue #2)
Added support for StrongReferenceNameValue
  • Loading branch information
palemieux committed Nov 28, 2014
1 parent b1c5f23 commit 10ce14f
Show file tree
Hide file tree
Showing 7 changed files with 956 additions and 18 deletions.
24 changes: 24 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,25 @@ XLSRegistersToXML: converts SMPTE registers contained in a spreadsheet to an

XMLRegistersToDict: converts XML-based registers to a RegXML metadictionary

GenerateXMLSchemaDocuments: generates XSDs for the Registers
created by XLSRegistersToXML


BUILD TARGETS
=============

build-regxml-schemas: generates a RegXML XSD at /dict/RegXML.xsd based on
the output of build-regxml-dict

build-xml-registers: generates XML-based Registers at /register based on
the contents of register/input (see DEPENDENCIES)

build-regxml-dict: generates a RegXML Metadictionary at /dict/RegXML.xml
based on the ouput of build-xml-registers

build-register-schemas: generates at /register/schemas the XSDs for the
Registers created by build-xml-registers

KNOWN ISSUES
============

Expand All @@ -72,6 +90,9 @@ DIRECTORIES AND NOTABLE FILES

/regxmllib/build.xml Build script (Ant)

/regxmllib/build.properties Constants, e.g. directory paths, used
by the build script

/regxmllib/nbproject Netbeans project files

/regxmllib/src/repoversion.properties Java properties file containing the
Expand All @@ -86,6 +107,9 @@ DIRECTORIES AND NOTABLE FILES

/register/input Stub directory for source CSV registers
extracted from [1]

/xsl/regxml-dict-to-xsd.xsl XSL Stylesheet used to generate a RegXML
XSD from a RegXML Metadictionary


DEPENDENCIES
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions regxmllib/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
elements.register=${register.dir}/ElementsRegister.xml
types.register=${register.dir}/TypesRegister.xml
labels.register=${register.dir}/LabelsRegister.xml
groups.register=${register.dir}/GroupsRegister.xml
register.dir=../register
register.schema.dir=${register.dir}/schemas

regxml.dict.dir=../dict
regxml.dict=${regxml.dict.dir}/RegXML.xml
regxml.schema=${regxml.dict.dir}/RegXML.xsd

46 changes: 33 additions & 13 deletions regxmllib/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<project name="regxmllib" default="default" basedir=".">
<description>Builds, tests, and runs the project RegXMLGenerator.</description>
<import file="nbproject/build-impl.xml"/>
<property file="build.properties"></property>

<target name="-post-init">
<echo file="${src.dir}/repoversion.properties">version=</echo>
Expand All @@ -20,14 +21,33 @@
<arg value="--pretty=format:%H"/>
</exec>
</target>

<!-- <target name="apply-xsl" depends="jar">
<java classname="com.sandflow.smpte.tools.ApplyXSL">
<arg value="-x"/>
<arg value="../xsl/regxml-dict-to-xsd.xsl"/>
<arg value="-i"/>
<arg value="${regxml.dict}"/>
<arg value="-o"/>
<arg value="${regxml.schema}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
</java>
</target>-->

<target name="build-regxml-schema" depends="build-regxml-dict">
<xslt style="../xsl/regxml-dict-to-xsd.xsl" in="${regxml.dict}" out="${regxml.schema}">
</xslt>
</target>

<target name="build-xml-registers" depends="jar,build-register-schemas">
<java classname="com.sandflow.smpte.tools.XLSRegistersToXML">
<arg value="-element"/>
<arg value="-i"/>
<arg value="../register/input/elements-smpte-ra-frozen-20140304.2118.csv"/>
<arg value="-o"/>
<arg value="../register/ElementsRegister.xml"/>
<arg value="${elements.register}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand All @@ -37,7 +57,7 @@
<arg value="-i"/>
<arg value="../register/input/types-smpte-ra-frozen-20140304.2118.csv"/>
<arg value="-o"/>
<arg value="../register/TypesRegister.xml"/>
<arg value="${types.register}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand All @@ -47,7 +67,7 @@
<arg value="-i"/>
<arg value="../register/input/labels-smpte-ra-frozen-20140304.2118.csv"/>
<arg value="-o"/>
<arg value="../register/LabelsRegister.xml"/>
<arg value="${labels.register}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand All @@ -58,7 +78,7 @@
<arg value="-i"/>
<arg value="../register/input/groups-smpte-ra-frozen-20140304.2118.csv"/>
<arg value="-o"/>
<arg value="../register/GroupsRegister.xml"/>
<arg value="${groups.register}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand All @@ -71,14 +91,14 @@
<target name="build-regxml-dict" depends="build-xml-registers">
<java classname="com.sandflow.smpte.tools.XMLRegistersToDict">
<arg value="-e"/>
<arg value="../register/ElementsRegister.xml"/>
<arg value="${elements.register}"/>
<arg value="-l"/>
<arg value="../register/LabelsRegister.xml"/>
<arg value="${labels.register}"/>
<arg value="-g"/>
<arg value="../register/GroupsRegister.xml"/>
<arg value="${groups.register}"/>
<arg value="-t"/>
<arg value="../register/TypesRegister.xml"/>
<arg value="../dict/regxml.xml"/>
<arg value="${types.register}"/>
<arg value="${regxml.dict}"/>

<classpath>
<pathelement location="${dist.jar}"/>
Expand All @@ -92,7 +112,7 @@
<arg value="-cp"/>
<arg value="com.sandflow.smpte.register.TypesRegister"/>
<arg value="-d"/>
<arg value="../schemas"/>
<arg value="${register.schema.dir}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand All @@ -102,7 +122,7 @@
<arg value="-cp"/>
<arg value="com.sandflow.smpte.register.LabelsRegister"/>
<arg value="-d"/>
<arg value="../schemas"/>
<arg value="${register.schema.dir}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand All @@ -112,7 +132,7 @@
<arg value="-cp"/>
<arg value="com.sandflow.smpte.register.ElementsRegister"/>
<arg value="-d"/>
<arg value="../schemas"/>
<arg value="${register.schema.dir}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand All @@ -122,7 +142,7 @@
<arg value="-cp"/>
<arg value="com.sandflow.smpte.register.GroupsRegister"/>
<arg value="-d"/>
<arg value="../schemas"/>
<arg value="${register.schema.dir}"/>
<classpath>
<pathelement location="${dist.jar}"/>
</classpath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.sandflow.smpte.register.exception.InvalidEntryException;
import com.sandflow.smpte.register.TypeEntry;
import com.sandflow.smpte.register.TypesRegister;
import com.sandflow.smpte.regxml.definition.StrongReferenceTypeDefinition;
import com.sandflow.smpte.util.AUID;
import com.sandflow.smpte.util.ExcelCSVParser;
import com.sandflow.smpte.util.UL;
import java.io.BufferedReader;
Expand Down Expand Up @@ -89,6 +91,19 @@ static public TypesRegister fromXLS(InputStream xlsfile) throws ExcelCSVParser.S
TypesRegister reg = new TypesRegister();

TypeEntry lasttype = null;


/* BUG: there is no StrongReferenceNameValue type */

TypeEntry entry = new TypeEntry();
entry.setKind(TypeEntry.Kind.LEAF);
entry.setDeprecated(false);
entry.setSymbol("StrongReferenceNameValue");
entry.setUL(UL.fromURN("urn:smpte:ul:060E2B34.01040101.05022900.00000000"));
entry.setName("StrongReferenceNameValue");
entry.setTypeKind(TypeEntry.STRONGREF_TYPEKIND);
entry.setBaseType(UL.fromDotValue("06.0E.2B.34.02.7F.01.01.0D.01.04.01.01.1F.01.00"));
reg.addEntry(entry);

for (AbstractList<String> fields; (fields = p.getLine()) != null;) {

Expand Down Expand Up @@ -185,11 +200,6 @@ static public TypesRegister fromXLS(InputStream xlsfile) throws ExcelCSVParser.S

type.setSymbol(fields.get(c.get("n:sym")));

/* BUG: there is no StrongReferenceNameValue type */
if (type.getSymbol().equals("StrongReferenceSetNameValue")) {
continue;
}

type.setDefiningDocument(fields.get(c.get("n:docs")));

if ("Leaf".equalsIgnoreCase(fields.get(c.get("n:node")))) {
Expand Down
83 changes: 83 additions & 0 deletions regxmllib/src/com/sandflow/smpte/tools/ApplyXSL.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package com.sandflow.smpte.tools;

import com.sandflow.smpte.register.exception.DuplicateEntryException;
import com.sandflow.smpte.register.exception.InvalidEntryException;
import com.sandflow.smpte.util.ExcelCSVParser;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.bind.JAXBException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

/**
*
* @author Pierre-Anthony Lemieux (pal@sandflow.com)
*/
public class ApplyXSL {

private final static String USAGE = "Applies an XSL stylesheet to a document.\n"
+ " Usage: ApplyXSLTTransform -x xslfile -i infile -o outfile\n"
+ " ApplyXSLTTransform -?";

public static void main(String[] args) throws FileNotFoundException, ExcelCSVParser.SyntaxException, JAXBException, IOException, InvalidEntryException, DuplicateEntryException, Exception {
if (args.length != 6
|| (!"-x".equals(args[0]))
|| (!"-i".equals(args[2]))
|| (!"-o".equals(args[4]))
|| "-?".equals(args[0])) {

System.out.println(USAGE);

return;
}

/* mute logging */
/* TODO: add switch to enable warnings */
Logger.getLogger("").setLevel(Level.OFF);
Source xsls = new StreamSource(args[1]);
Source is = new StreamSource(args[3]);
StreamResult or = new StreamResult(args[5]);

TransformerFactory tf = TransformerFactory.newInstance();

tf.setAttribute("debug", Boolean.TRUE);

Transformer tr = tf.newTransformer(xsls);


tr.setOutputProperty(OutputKeys.INDENT, "yes");
tr.transform(is, or);

}
}
Loading

0 comments on commit 10ce14f

Please sign in to comment.