Dev:catalog: Difference between revisions

From railML 2 Wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
mNo edit summary
m (Wiki Layout corrected)
Line 7: Line 7:
In order to validate the correct structure and syntax of your railML file, it has to comply the following conditions:
In order to validate the correct structure and syntax of your railML file, it has to comply the following conditions:


* The root element should be one of [[CO:railml | railml]], [[IS:infrastructure | infrastructure]], [[RS:rollingstock | rollingstock]] or [[TT:timetable | timetable]].
<ul>
*:<pre>
<li> The root element should be one of [[CO:railml | railml]], [[IS:infrastructure | infrastructure]], [[RS:rollingstock | rollingstock]] or [[TT:timetable | timetable]]<pre>
*:<railml ...>
<railml ...>
*:  ...
  ...
*:</railml>
</railml>
*:</pre>
</pre></li>
* The root element should contain an "attribute" which defines the reserved <tt>xsi</tt> namespace.
<li>The root element should contain an "attribute" which defines the reserved <tt>xsi</tt> namespace.<pre>
*:<pre>
<railml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
*:<railml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
*: ...
</railml>
*:</railml>
</pre></li>
*:</pre>
<li>The root element should contain an "attribute" which defines the railML namespace. <pre>
* The root element should contain an "attribute" which defines the railML namespace.  
<railml xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
*:<pre>
...
*:<railml xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</railml>
*: ...
</pre>
*:</railml>
The example shows the simplified version using the default namespace definition.
*:</pre>
Example files in the [http://www.railml.org railML repository] show usage of namespace prefixes as alternative to the default namespace.</li>
*: The example shows the simplified version using the default namespace definition.
<li>The root element should contain an attribute which defines the file location of its XML schema.
*: Example files in the [http://www.railml.org railML repository] show usage of namespace prefixes as alternative to the default namespace.
<tt>xsi:schemaLocation</tt> contains the railML namespace and an according file path to the XML Schema file (railML.xsd) separated by whitespace.
* The root element should contain an attribute which defines the file location of its XML schema.  
This condition can be fulfilled using different mechanism. (see following subsections)</li></ul>
*: <tt>xsi:schemaLocation</tt> contains the railML namespace and an according file path to the XML Schema file (railML.xsd) separated by whitespace.
*: This condition can be fulfilled using different mechanism. (see following subsections)


=== Local validation ===
=== Local validation ===
Line 35: Line 33:
The XML Schema files were downloaded to your local file system where your railML file is located.
The XML Schema files were downloaded to your local file system where your railML file is located.


* Absolute file path
<ul>
*:<pre>
<li>Absolute file path<pre>
*:<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 c:/project-railml/schema/railML.xsd"  
<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 c:/project-railml/schema/railML.xsd"  
*:  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
*: ...
...
*:</railml>
</railml>
*:</pre>
</pre></li>
* Relative file path
<li>Relative file path<pre>
*:<pre>
<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 ../schema/railML.xsd"  
*:<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 ../schema/railML.xsd"  
  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
*:  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
*: ...
</railml>
*:</railml>
</pre></li></ul>
*:</pre>


; Note 1 : You have to assure that all other XML Schema files are located in the same folder together with the file <tt>railML.xsd</tt>.
; Note 1 : You have to assure that all other XML Schema files are located in the same folder together with the file <tt>railML.xsd</tt>.
Line 57: Line 54:
The XML Schema files are located on the railML Web-server.
The XML Schema files are located on the railML Web-server.


* Web-based URI
<ul>
*:<pre>
<li>Web-based URI<pre>
*:<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 http://www.railml.org/schemas/2009/railML-2.0/railML.xsd"  
<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 http://www.railml.org/schemas/2009/railML-2.0/railML.xsd"  
*:  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
*: ...
...
*:</railml>
</railml>
*:</pre>
</pre></li></ul>


; Note 3 : Your local environment has to allow your validation tool to access the railML Web-server. There may be '''troubles with firewalls''' or something like that.
; Note 3 : Your local environment has to allow your validation tool to access the railML Web-server. There may be '''troubles with firewalls''' or something like that.
Line 71: Line 68:
Your railML file contains the web-based URI as XML schema location but your validation tool knows the file path to a local copy of the XML schema set.
Your railML file contains the web-based URI as XML schema location but your validation tool knows the file path to a local copy of the XML schema set.


* Web-based URI
<ul>
*:<pre>
<li>Web-based URI<pre>
*:<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 http://www.railml.org/schemas/2009/railML-2.0/railML.xsd"  
<railml xsi:schemaLocation="http://www.railml.org/schemas/2009 http://www.railml.org/schemas/2009/railML-2.0/railML.xsd"  
*:  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
*: ...
...
*:</railml>
</railml>
*:</pre>
</pre>


This szenario uses the [http://www.oasis-open.org/committees/entity/spec-2001-08-06.html OASIS XML Catalogs specification]. Your validation tool contains an XML catalog file which conforms the OASIS XML Catalogs requirements in structure and content.
This szenario uses the [http://www.oasis-open.org/committees/entity/spec-2001-08-06.html OASIS XML Catalogs specification]. Your validation tool contains an XML catalog file which conforms the OASIS XML Catalogs requirements in structure and content.</li>


* XML Catalog example
<li>XML Catalog example<pre>
*: <pre>
<?xml version="1.0" encoding="UTF-8"?>
*:<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
*:<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/>
*:  <system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/>
  <uri name="http://www.railml.org/schemas/2009" uri="../schema/railML.xsd"/>
*:  <uri name="http://www.railml.org/schemas/2009" uri="../schema/railML.xsd"/>
</catalog>
*:</catalog>
</pre>
*: </pre>


The validation uses the first entry which matches either the "schema location" or the "namespace name" of your railML file.
The validation uses the first entry which matches either the "schema location" or the "namespace name" of your railML file.</li>


* Schema location match
<li>Schema location match<pre><system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/></pre>
*:<pre><system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/></pre>
Attribute <tt>systemId</tt> in element <tt>system</tt> contains identically the same string as the <tt>xsi:schemaLocation</tt> attribute of your railML file.
*: Attribute <tt>systemId</tt> in element <tt>system</tt> contains identically the same string as the <tt>xsi:schemaLocation</tt> attribute of your railML file.
The validation tool uses the XML Schema at the <tt>uri</tt> file path instead of the web-based version.</li>
*: The validation tool uses the XML Schema at the <tt>uri</tt> file path instead of the web-based version.
<li>Namespace name match<pre><uri name="http://www.railml.org/schemas/2009" uri="../schema/railML.xsd"/></pre>
* Namespace name match
Attribute <tt>name</tt> in element <tt>uri</tt> contains identically the same string as the <tt>xmlns</tt> attribute of your railML file.
*:<pre><uri name="http://www.railml.org/schemas/2009" uri="../schema/railML.xsd"/></pre>
The validation tool uses the XML Schema at the <tt>uri</tt> file path instead of the declared path at the <tt>schemaLocation</tt></li></ul>
*: Attribute <tt>name</tt> in element <tt>uri</tt> contains identically the same string as the <tt>xmlns</tt> attribute of your railML file.
*: The validation tool uses the XML Schema at the <tt>uri</tt> file path instead of the declared path at the <tt>schemaLocation</tt>


; Note 4: The <tt>uri</tt> attribute can specify absolute or relative file pathes.
; Note 4: The <tt>uri</tt> attribute can specify absolute or relative file pathes.
Line 113: Line 107:
[http://www.altova.com/xmlspy.html Altova XMLSpy] supports [http://manual.altova.com/XMLSpy/spyenterprise/xsdtdandxsd_catalogs.htm XML catalogs].
[http://www.altova.com/xmlspy.html Altova XMLSpy] supports [http://manual.altova.com/XMLSpy/spyenterprise/xsdtdandxsd_catalogs.htm XML catalogs].


* Edit the file named "CustomCatalog.xml" in the local folder where XMLSpy is installed into. This is typically "%PersonalFolder%/Altova/%AppAndVersionName%/" or, under Microsoft Windows, "%ProgramsFolder%/Altova/XMLSpy%Version%/".
<ul>
* Use the <tt>uri</tt> element with the "schema location" string.
<li>Edit the file named "CustomCatalog.xml" in the local folder where XMLSpy is installed into. This is typically "%PersonalFolder%/Altova/%AppAndVersionName%/" or, under Microsoft Windows, "%ProgramsFolder%/Altova/XMLSpy%Version%/".</li>
*:<pre><uri name="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/></pre>
<li>Use the <tt>uri</tt> element with the "schema location" string.<pre><uri name="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/></pre></li>
* Restart Altova XMLSpy and validate your railML file.
<li>Restart Altova XMLSpy and validate your railML file.</li></ul>


=== Apache Ant (with Xerces) ===
=== Apache Ant (with Xerces) ===
Line 124: Line 118:
It includes catalog entries in its <tt>schemavalidate</tt> task, not conforming with [http://www.oasis-open.org/committees/entity/spec-2001-08-06.html OASIS XML Catalogs], but it works. :-)
It includes catalog entries in its <tt>schemavalidate</tt> task, not conforming with [http://www.oasis-open.org/committees/entity/spec-2001-08-06.html OASIS XML Catalogs], but it works. :-)


* Use the "namespace name" for matching the schema.
<ul>
*:<pre>
<li>Use the "namespace name" for matching the schema.<pre>
*:<schemavalidate file="myRailML.xml">
<schemavalidate file="myRailML.xml">
*:  <schema namespace="http://www.railml.org/schemas/2009" file="schema/railML.xsd"/>
  <schema namespace="http://www.railml.org/schemas/2009" file="schema/railML.xsd"/>
*:</schemavalidate>
</schemavalidate>
*:</pre>
</pre></li>


In order to assure full validation of well-formed XML against XML Schema you can use Xerces with some additional flags/parameter:
<li>In order to assure full validation of well-formed XML against XML Schema you can use Xerces with some additional flags/parameter:


<pre>
<pre>
Line 145: Line 139:
</pre>
</pre>


This way you have to define the property value of ${xml-file} with your to be validated railML file (e.g. "myRailML").
This way you have to define the property value of ${xml-file} with your to be validated railML file (e.g. "myRailML").</li></ul>


; Note 1: Manual of [http://ant.apache.org/manual/Tasks/xmlvalidate.html <tt>xmlvalidate</tt> task] states: "The schemavalidate task is better for validating W3C XML Schemas, as it extends this task with the right options automatically enabled, and makes it easy to add a list of schema files/URLs to act as sources."
; Note 1: Manual of [http://ant.apache.org/manual/Tasks/xmlvalidate.html <tt>xmlvalidate</tt> task] states: "The schemavalidate task is better for validating W3C XML Schemas, as it extends this task with the right options automatically enabled, and makes it easy to add a list of schema files/URLs to act as sources."
Line 155: Line 149:
[http://www.eclipse.org/webtools/community/tutorials/XMLWizards/XMLWizards.html Eclipse Webtools (WTP)] support [http://www.eclipse.org/webtools/community/tutorials/XMLCatalog/XMLCatalogTutorial.html XML catalogs].
[http://www.eclipse.org/webtools/community/tutorials/XMLWizards/XMLWizards.html Eclipse Webtools (WTP)] support [http://www.eclipse.org/webtools/community/tutorials/XMLCatalog/XMLCatalogTutorial.html XML catalogs].


* Select "Window > Preferences > XML > XML Catalog".
<ul>
* Add new catalog entry with "Add".
<li>Select "Window > Preferences > XML > XML Catalog".</li>
* "Location" allows you browsing to your local XML Schema copy.
<li>Add new catalog entry with "Add".</li>
* For "Key Type" you can choose between "Namespace Name" and "Schema Location"
<li>"Location" allows you browsing to your local XML Schema copy.</li>
* The "Key" is by default filled with the "namespace name", alternatively you can enter the "schema location" string of your railML file.
<li>For "Key Type" you can choose between "Namespace Name" and "Schema Location"</li>
* Re-start Eclipse and validate your railML file.
<li>The "Key" is by default filled with the "namespace name", alternatively you can enter the "schema location" string of your railML file.</li>
<li>Re-start Eclipse and validate your railML file.</li></ul>


=== <oXygen/> ===
=== <oXygen/> ===
Line 166: Line 161:
[http://www.oxygenxml.com/ <oXygen/>] supports [http://www.oxygenxml.com/doc/ug-oxygen/topics/using-XML-Catalogs.html XML catalogs].  
[http://www.oxygenxml.com/ <oXygen/>] supports [http://www.oxygenxml.com/doc/ug-oxygen/topics/using-XML-Catalogs.html XML catalogs].  


* You have to create the catalog file, maybe supported by the according "Document Template".
<ul>
*:Use the <tt>system</tt> element with the "schema location" string
<li>You have to create the catalog file, maybe supported by the according "Document Template".
*:<pre><system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="schema/railML.xsd"/></pre>
Use the <tt>system</tt> element with the "schema location" string<pre><system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="schema/railML.xsd"/></pre></li>
* This file should be saved in your current project folder, typically as "catalog.xml".
<li>This file should be saved in your current project folder, typically as "catalog.xml".</li>
* Select [http://www.oxygenxml.com/doc/ug-oxygen/topics/preferences-xml-catalog.html "Options > Preferences ... > XML > XML Catalog"].
<li>Select [http://www.oxygenxml.com/doc/ug-oxygen/topics/preferences-xml-catalog.html "Options > Preferences ... > XML > XML Catalog"].</li>
* Add current catalog file with "New".
<li>Add current catalog file with "New".</li>
* Re-start <oXygen/> and validate your railML file.
<li>Re-start <oXygen/> and validate your railML file.</li></ul>


== Further railML related catalog entries ==
== Further railML related catalog entries ==
Line 184: Line 179:
How to define an XML catalog entry for Dublin Core metadata?
How to define an XML catalog entry for Dublin Core metadata?


* Use of "namespace name":
<ul>
*:<pre>"http://purl.org/dc/elements/1.1/"</pre>
<li>Use of "namespace name":<pre>"http://purl.org/dc/elements/1.1/"</pre></li>
* Use of "schema location":
<li>Use of "schema location":<pre>"http://dublincore.org/schemas/xmls/qdc/dc.xsd"</pre></li>
*:<pre>"http://dublincore.org/schemas/xmls/qdc/dc.xsd"</pre>
<li>Point to local XML Schema <tt>dc.xsd</tt></li></ul>
* Point to local XML Schema <tt>dc.xsd</tt>


=== MathML ===
=== MathML ===
Line 200: Line 194:
How to define an XML catalog entry for MathML?
How to define an XML catalog entry for MathML?


* Use of "namespace name":
<ul>
*:<pre>"http://www.w3.org/1998/Math/MathML"</pre>
<li>Use of "namespace name":<pre>"http://www.w3.org/1998/Math/MathML"</pre></li>
* Use of "schema location":
<li>Use of "schema location":<pre>"http://www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd"</pre></li>
*:<pre>"http://www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd"</pre>
<li>Point to local XML Schema <tt>mathml2.xsd</tt></li></ul>
* Point to local XML Schema <tt>mathml2.xsd</tt>


=== xml.xsd ===
=== xml.xsd ===
Line 214: Line 207:
Nevertheless, how to define an XML catalog entry for <tt>xml.xsd</tt>?
Nevertheless, how to define an XML catalog entry for <tt>xml.xsd</tt>?


* Use of "namespace name":
<ul>
*:<pre>"http://www.w3.org/XML/1998/namespace"</pre>
<li>Use of "namespace name":<pre>"http://www.w3.org/XML/1998/namespace"</pre></li>
* Use of "schema location":
<li>Use of "schema location":<pre>"http://www.w3.org/2001/03/xml.xsd"</pre></li>
*:<pre>"http://www.w3.org/2001/03/xml.xsd"</pre>
<li>Point to local XML Schema <tt>xml.xsd</tt></li></ul>
* Point to local XML Schema <tt>xml.xsd</tt>


----
----

Revision as of 11:53, 12 April 2012

Validating railML files

Structure and content types of railML files are defined in XML Schema. railML is based on a couple of such XSD files which require each other.

Basics

In order to validate the correct structure and syntax of your railML file, it has to comply the following conditions:

  • The root element should be one of railml, infrastructure, rollingstock or timetable
    <railml ...>
      ...
    </railml>
    
  • The root element should contain an "attribute" which defines the reserved xsi namespace.
    <railml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     ...
    </railml>
    
  • The root element should contain an "attribute" which defines the railML namespace.
    <railml xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     ...
    </railml>
    

    The example shows the simplified version using the default namespace definition.

    Example files in the railML repository show usage of namespace prefixes as alternative to the default namespace.
  • The root element should contain an attribute which defines the file location of its XML schema. xsi:schemaLocation contains the railML namespace and an according file path to the XML Schema file (railML.xsd) separated by whitespace. This condition can be fulfilled using different mechanism. (see following subsections)

Local validation

The XML Schema files were downloaded to your local file system where your railML file is located.

  • Absolute file path
    <railml xsi:schemaLocation="http://www.railml.org/schemas/2009 c:/project-railml/schema/railML.xsd" 
      xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     ...
    </railml>
    
  • Relative file path
    <railml xsi:schemaLocation="http://www.railml.org/schemas/2009 ../schema/railML.xsd" 
      xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     ...
    </railml>
    
Note 1
You have to assure that all other XML Schema files are located in the same folder together with the file railML.xsd.
Note 2
If you transfer the railML file to partners they might not validate it. Either they have to adjust all file paths or you transfer the railML together with its XML Schema files.

Web-based validation

The XML Schema files are located on the railML Web-server.

  • Web-based URI
    <railml xsi:schemaLocation="http://www.railml.org/schemas/2009 http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" 
      xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     ...
    </railml>
    
Note 3
Your local environment has to allow your validation tool to access the railML Web-server. There may be troubles with firewalls or something like that.

Validation using a local copy of the web-based URI (XML Catalog)

Your railML file contains the web-based URI as XML schema location but your validation tool knows the file path to a local copy of the XML schema set.

  • Web-based URI
    <railml xsi:schemaLocation="http://www.railml.org/schemas/2009 http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" 
      xmlns="http://www.railml.org/schemas/2009" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     ...
    </railml>
    
    This szenario uses the OASIS XML Catalogs specification. Your validation tool contains an XML catalog file which conforms the OASIS XML Catalogs requirements in structure and content.
  • XML Catalog example
    <?xml version="1.0" encoding="UTF-8"?>
    <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
      <system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/>
      <uri name="http://www.railml.org/schemas/2009" uri="../schema/railML.xsd"/>
    </catalog>
    
    The validation uses the first entry which matches either the "schema location" or the "namespace name" of your railML file.
  • Schema location match
    <system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/>

    Attribute systemId in element system contains identically the same string as the xsi:schemaLocation attribute of your railML file.

    The validation tool uses the XML Schema at the uri file path instead of the web-based version.
  • Namespace name match
    <uri name="http://www.railml.org/schemas/2009" uri="../schema/railML.xsd"/>

    Attribute name in element uri contains identically the same string as the xmlns attribute of your railML file.

    The validation tool uses the XML Schema at the uri file path instead of the declared path at the schemaLocation
Note 4
The uri attribute can specify absolute or relative file pathes.
Note 5
If you transfer the railML file to partners they might validate using the web-based schema location. Alternatively they could also create an XML catalog entry for railML and validate using a local copy. They don't have to touch the railML files.
Note 6
If you have defined such an XML catalog entry for railML it works for all railML files you create your own or get from others.

Implementation of XML catalogs in some XML validation tools

This is an to be completed list of XML validation tools supporting XML catalogs.

Altova XMLSpy

Altova XMLSpy supports XML catalogs.

  • Edit the file named "CustomCatalog.xml" in the local folder where XMLSpy is installed into. This is typically "%PersonalFolder%/Altova/%AppAndVersionName%/" or, under Microsoft Windows, "%ProgramsFolder%/Altova/XMLSpy%Version%/".
  • Use the uri element with the "schema location" string.
    <uri name="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="c:/project-railml/schema/railML.xsd"/>
  • Restart Altova XMLSpy and validate your railML file.

Apache Ant (with Xerces)

Apache Ant supports XML catalogs.

It includes catalog entries in its schemavalidate task, not conforming with OASIS XML Catalogs, but it works. :-)

  • Use the "namespace name" for matching the schema.
    <schemavalidate file="myRailML.xml">
      <schema namespace="http://www.railml.org/schemas/2009" file="schema/railML.xsd"/>
    </schemavalidate>
    
  • In order to assure full validation of well-formed XML against XML Schema you can use Xerces with some additional flags/parameter:
    <target name="xml-validate" description="Validate ${xml-file} against its schema files">
      <schemavalidate file="${xml-file}.xml" classname="org.apache.xerces.parsers.SAXParser">
        <schema namespace="http://www.railml.org/schemas/2009" file="railML-2-0/schema/railML.xsd"/>
        <attribute name="http://xml.org/sax/features/validation" value="true"/>
        <attribute name="http://apache.org/xml/features/validation/schema" value="true"/>
        <attribute name="http://xml.org/sax/features/namespaces" value="true"/>
        <attribute name="http://xml.org/sax/features/namespace-prefixes" value="true"/>
      </schemavalidate>
    </target>
    
    This way you have to define the property value of ${xml-file} with your to be validated railML file (e.g. "myRailML").
Note 1
Manual of xmlvalidate task states: "The schemavalidate task is better for validating W3C XML Schemas, as it extends this task with the right options automatically enabled, and makes it easy to add a list of schema files/URLs to act as sources."
Note 2
Look at the "xmlvalidate with xmlcatalog" thread (apache ant mailing list) for reasons not to use xmlvalidate.
Note 3
For all who want in spite of everthing test built-in catalog entries, look at the xmlcatalog manual.

Eclipse Webtools (WTP)

Eclipse Webtools (WTP) support XML catalogs.

  • Select "Window > Preferences > XML > XML Catalog".
  • Add new catalog entry with "Add".
  • "Location" allows you browsing to your local XML Schema copy.
  • For "Key Type" you can choose between "Namespace Name" and "Schema Location"
  • The "Key" is by default filled with the "namespace name", alternatively you can enter the "schema location" string of your railML file.
  • Re-start Eclipse and validate your railML file.

<oXygen/>

<oXygen/> supports XML catalogs.

  • You have to create the catalog file, maybe supported by the according "Document Template". Use the system element with the "schema location" string
    <system systemId="http://www.railml.org/schemas/2009/railML-2.0/railML.xsd" uri="schema/railML.xsd"/>
  • This file should be saved in your current project folder, typically as "catalog.xml".
  • Select "Options > Preferences ... > XML > XML Catalog".
  • Add current catalog file with "New".
  • Re-start <oXygen/> and validate your railML file.

Further railML related catalog entries

Dublin Core

Dublin Core Metadata Initiative (DCMI) provides an XML Schema (set) for metadata "to facilitate the finding, sharing and management of information".

railML integrates Dublin Core metadata with its metadata element.

How to define an XML catalog entry for Dublin Core metadata?

  • Use of "namespace name":
    "http://purl.org/dc/elements/1.1/"
  • Use of "schema location":
    "http://dublincore.org/schemas/xmls/qdc/dc.xsd"
  • Point to local XML Schema dc.xsd

MathML

MathML provides XML Schema (set) for quite all mathematical expressions.

railML integrated MathML up to version 2.0 into its valueTable element.

Since railML 2.1 the inclusion of MathML in valueTable is optional. If you don't use it, you don't have to access MathML XML Schema files for validation purposes.

How to define an XML catalog entry for MathML?

  • Use of "namespace name":
    "http://www.w3.org/1998/Math/MathML"
  • Use of "schema location":
    "http://www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd"
  • Point to local XML Schema mathml2.xsd

xml.xsd

Since railML 2.0 outsourcing of subschema parts is allowed using XML Base implemented in the xml.xsd XML Schema.

Most XML validation tools have built-in support for this file and its attribute xml:base.

Nevertheless, how to define an XML catalog entry for xml.xsd?

  • Use of "namespace name":
    "http://www.w3.org/XML/1998/namespace"
  • Use of "schema location":
    "http://www.w3.org/2001/03/xml.xsd"
  • Point to local XML Schema xml.xsd

Please send any comments about validation handling and XML catalogs regarding named and unnamed tools to Common coordinator .

Back to Common overview