Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » xsd2ttcn and Relax NG schema(TTCN-3 'Relax NG schema' xsd2ttcn)
xsd2ttcn and Relax NG schema [message #1792021] Tue, 10 July 2018 07:47 Go to next message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 145
Registered: June 2016
Senior Member
Dear All,

I would known if xsd2ttcn tool support native NG Relax schema as defined by OASIS or it's XML schema equivalent (e.g. RFC 5222 Annex A)?

Many thanks in advance,

Best Regards,

Yann
Re: xsd2ttcn and Relax NG schema [message #1792035 is a reply to message #1792021] Tue, 10 July 2018 11:41 Go to previous messageGo to next message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 1120
Registered: January 2015
Senior Member
Hi Yann,


it does not support it directly; however there's a workflow that can be applied , but it will require some tweaking:

there is a tool Trang (http://www.thaiopensource.com/relaxng/trang.html) which converts RelaxNG XML into the corresponding XML Schema (XSD); from here on xsd2ttcn can be used.
However please be aware that Trang , as well as xsd2ttcn have their own idiosyncrasies, not all conversions are perfect so one will need to add some effort into it.


Let's consider the attached simple example:

-the RelaxNG XML (simpledc.rng) can be converted with Trang:

trang -I rng -O xsd simpledc.rng simpledc.xsd


However note here that Trang during the conversion loses the target namespace so I had to add that manually.

in simpledc.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://relaxng.org/ns/structure/1.0" xmlns="http://relaxng.org/ns/structure/1.0" elementFormDefault="qualified">
  <xs:element name="dc">
  :
:


From here on


xsd2ttcn simpledc.xsd 
makefilegen *.ttcn
make



will work smoothly; the resulting TTCN-3 module looks credible:

module http_relaxng_org_ns_structure_1_0 {


import from XSD all;


type record Dc
{
	Creator creator,
	Title title,
	Date date,
	record of Publisher publisher_list,
	record of Source source_list,
	record of Description description_list,
	record of Subject subject_list,
	record of Coverage coverage_list,
	record of Contributor contributor_list,
	record of Identifier identifier_list,
	record of Relation relation_list,
	record of Rights rights_list,
	record of Language language_list,
	record of Type type_list,
	record of Format format_list
}
with {
  variant "name as uncapitalized";
  variant "element";
  variant (publisher_list) "untagged";
  variant (publisher_list[-]) "name as 'publisher'";
  variant (source_list) "untagged";
  variant (source_list[-]) "name as 'source'";
  variant (description_list) "untagged";
  variant (description_list[-]) "name as 'description'";
  variant (subject_list) "untagged";
  variant (subject_list[-]) "name as 'subject'";
  variant (coverage_list) "untagged";
  variant (coverage_list[-]) "name as 'coverage'";
  variant (contributor_list) "untagged";
  variant (contributor_list[-]) "name as 'contributor'";
  variant (identifier_list) "untagged";
  variant (identifier_list[-]) "name as 'identifier'";
  variant (relation_list) "untagged";
  variant (relation_list[-]) "name as 'relation'";
  variant (rights_list) "untagged";
  variant (rights_list[-]) "name as 'rights'";
  variant (language_list) "untagged";
  variant (language_list[-]) "name as 'language'";
  variant (type_list) "untagged";
  variant (type_list[-]) "name as 'type'";
  variant (format_list) "untagged";
  variant (format_list[-]) "name as 'format'";
};


type XSD.String Creator
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Title
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Date
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Publisher
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Source
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Description
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Subject
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Coverage
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Contributor
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Identifier
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Relation
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Rights
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Language
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Type
with {
  variant "name as uncapitalized";
  variant "element";
};


type XSD.String Format
with {
  variant "name as uncapitalized";
  variant "element";
};


}
with {
  encode "XML";
  variant "namespace as 'http://relaxng.org/ns/structure/1.0'";
  variant "controlNamespace 'http://www.w3.org/2001/XMLSchema-instance' prefix 'xsi'";
  variant "elementFormQualified";
}



compared to the initial .rng file :


<?xml version="1.0" encoding="UTF-8"?>
 <element name="dc" xmlns="http://relaxng.org/ns/structure/1.0">
	<element name="creator">
		<text />
	</element>
	<element name="title">
		<text />
	</element>
	<element name="date">
		<text />
	</element>
	<zeroOrMore>
		<element name="publisher">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="source">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="description">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="subject">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="coverage">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="contributor">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="identifier">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="relation">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="rights">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="language">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="type">
			<text />
		</element>
	</zeroOrMore>
	<zeroOrMore>
		<element name="format">
			<text />
		</element>
	</zeroOrMore>
	
 </element>




I have also tried to convert the Annex A you have mentioned as an RNG file;
(see also attached)
but when running xsd2ttcn, it throws a number of errors saying that "The content model is not deterministic".

This can be reduced to this code snippet:


 <xs:group name="notLost">
    <xs:annotation>
      <xs:documentation>
  Any element not in the LoST namespace.
</xs:documentation>
    </xs:annotation>
    <xs:choice>
      <!-- xs:any namespace="##other" processContents="skip"/-->
      <xs:any namespace="##local" processContents="skip"/>
    </xs:choice>
  </xs:group>


which apparently leads to a contradictory definition , unless one of the any namespace definitions are removed.

Also, there seems to be a problem with

 <xs:attributeGroup name="expires">
    <xs:attribute name="expires" use="required">
      <!--xs:simpleType>
        <xs:union memberTypes="xs:dateTime">
          <xs:simpleType>
            <xs:restriction base="xs:token">
              <xs:enumeration value="NO-CACHE"/>
            </xs:restriction>
          </xs:simpleType>
          <xs:simpleType>
            <xs:restriction base="xs:token">
              <xs:enumeration value="NO-EXPIRATION"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:union>
      </xs:simpleType-->
    </xs:attribute>
  </xs:attributeGroup>


that has to be looked into.

But with these fixes ( the lines which are commented out ) it compiles.

Of course the details have to be ironed out but there seems to be a usable workflow.


I hope this helps


Best regards
Elemer


[Updated on: Tue, 10 July 2018 12:09]

Report message to a moderator

Re: xsd2ttcn and Relax NG schema [message #1792043 is a reply to message #1792035] Tue, 10 July 2018 13:08 Go to previous message
Yann Garcia is currently offline Yann GarciaFriend
Messages: 145
Registered: June 2016
Senior Member
Hello Elemer,

Many thanks for your help,

Best Regards,

Yann
Previous Topic:Eclipse Titan CRL 113 200/6 R4A release notification
Next Topic:Issues with xsd2ttcn
Goto Forum:
  


Current Time: Thu Apr 18 13:40:52 GMT 2024

Powered by FUDForum. Page generated in 0.01733 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top