Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First draft of RNG and XML #19

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions rng/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="conversion.rnc" type="application/relax-ng-compact-syntax"?>
<config version="1.0">
<cleantmp>false</cleantmp>
<outputdir>conv</outputdir>

<files ditamap="overview.ditamap">
<replace source="shared/gettingstarted/intro-copyright.xml" target="copyright_socm.xml"/>
</files>
<files ditamap="msoperator.ditamap">
<replace source="shared/gettingstarted/intro-copyright.xml" target="copyright_socm.xml"/>
<remove source="shared/gettingstarted/intro-trademarks.xml"/>
<remove source="cmmoperator/install/c-cmmoprepare.xml"/>
</files>
</config>
71 changes: 71 additions & 0 deletions rng/conversion.rnc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# RELAX NG Schema for the conversion.xml file
#
# Author: 2017 Thomas Schraitle

c.file.source.attrib =
## the source filename
attribute source { text }

c.file.target.attrib =
## the target filename
attribute target { text }

c.remove =
## Remove this filename
element remove { c.file.source.attrib, empty }

c.replace =
## Replace this filename from source to target
element replace { c.file.source.attrib, c.file.target.attrib, empty }

c.files.ditamap.attrib =
## filename to DITAMap
attribute ditamap { xsd:anyURI }

c.files.attributes =
c.files.ditamap.attrib

c.files =
## a list of files
element files {
c.files.attributes,
(c.replace* & c.remove*)+
}

div {
c.styleroot =
## where the stylesheets are located
element styleroot { text }
c.outputdir =
## where to save the converted files
element outputdir { "converted" | text }
c.entityfile =
## our entity file
element entityfile { "entities.ent" | text }
c.cleanids =
## User option: Clean up unused IDs?
element cleanids { xsd:boolean }
c.cleantmp =
## Dev option: Clean temporary directory after transformation?
element cleantmp { xsd:boolean }
}

div {
c.config.version.attrib =
## The version of this schema
attribute version { "1.0" }?

c.config.attributes = c.config.version.attrib

c.config =
## root element of the configuration file
element config { c.config.attributes,
(c.styleroot? &
c.entityfile? &
c.outputdir? &
c.cleanids? &
c.cleantmp? )?,
c.files* }
}

start = c.config
112 changes: 112 additions & 0 deletions rng/conversion.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<!--
RELAX NG Schema for the conversion.xml file


Author: 2017 Thomas Schraitle
-->
<define name="c.file.source.attrib">
<attribute name="source">
<a:documentation>the source filename</a:documentation>
<data type="anyURI"/>
</attribute>
</define>
<define name="c.file.target.attrib">
<attribute name="target">
<a:documentation>the target filename</a:documentation>
<data type="anyURI"/>
</attribute>
</define>
<define name="c.remove">
<element name="remove">
<a:documentation>Remove this filename</a:documentation>
<ref name="c.file.source.attrib"/>
<empty/>
</element>
</define>
<define name="c.replace">
<element name="replace">
<a:documentation>Replace this filename from source to target</a:documentation>
<ref name="c.file.source.attrib"/>
<ref name="c.file.target.attrib"/>
<empty/>
</element>
</define>
<define name="c.files.ditamap.attrib">
<attribute name="ditamap">
<a:documentation>filename to DITAMap</a:documentation>
<data type="anyURI"/>
</attribute>
</define>
<define name="c.files.attributes">
<ref name="c.files.ditamap.attrib"/>
</define>
<define name="c.files">
<element name="files">
<a:documentation>a list of files</a:documentation>
<ref name="c.files.attributes"/>
<oneOrMore>
<interleave>
<zeroOrMore>
<ref name="c.replace"/>
</zeroOrMore>
<zeroOrMore>
<ref name="c.remove"/>
</zeroOrMore>
</interleave>
</oneOrMore>
</element>
</define>
<div>
<define name="c.property.key.attrib">
<attribute name="key">
<a:documentation>the key of an property</a:documentation>
</attribute>
</define>
<define name="c.property.value.attrib">
<attribute name="value">
<a:documentation>the value of an property</a:documentation>
</attribute>
</define>
<define name="c.property.attibutes">
<ref name="c.property.key.attrib"/>
<ref name="c.property.value.attrib"/>
</define>
<define name="c.property">
<element name="property">
<a:documentation>General property</a:documentation>
<ref name="c.property.attibutes"/>
<empty/>
</element>
</define>
</div>
<div>
<define name="c.config.version.attrib">
<optional>
<attribute name="version">
<a:documentation>The version of this schema</a:documentation>
<value>1.0</value>
</attribute>
</optional>
</define>
<define name="c.config.attributes">
<ref name="c.config.version.attrib"/>
</define>
<define name="c.config">
<element name="config">
<a:documentation>root element of the configuration file</a:documentation>
<ref name="c.config.attributes"/>
<zeroOrMore>
<ref name="c.property"/>
</zeroOrMore>
<zeroOrMore>
<ref name="c.files"/>
</zeroOrMore>
</element>
</define>
</div>
<start>
<ref name="c.config"/>
</start>
</grammar>