Topics to be covered:
Tasks are to express the following information:
Important for the solution is where to put its information in the schema and / or document instance, and how to interpret that information. For this purpose, we establish four conventions:
Task 1 (for a specific doctype translate "yes" or "no" (a doc with a schema)): add the its:info element to the xs:annotation element of the root element. Set the value of the translatability attribute to "yes" or "no".
<xs:element name="myFile">
<xs:annotation>
<xs:appinfo>
<its:info>
<its:translate translatability="yes"/>
</its:info>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element ref="myns:myElement" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Task 2 (for a specific doc translate "yes" or "no" (a doc without a schema)): add the its:info element as the first child of the root element in the instance.
<myns:myFile xmlns:its="http://example.com/its"
xmlns:myns="http://example.com/mysn">
<its:info>
<its:translate translatability="yes"/>
</its:info>
[...]
</myns:myElement>
</myns:myFile>
Task 3 (for an element in general translate "yes" or "no" (a schema exists)): add the its:info element to the xs:annotation element of that element. Restrict the value of the translatability attribute to "yes" or "no".
<xs:element name="myElement" mixed="true">
<xs:annotation>
<xs:appinfo>
<its:info>
<its:translate translatability="yes"/>
</its:info>
</xs:appinfo>
</xs:annotation>
<xs:complexType mixed="true">
<xs:attribute name="myAttr" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
Task 4 (for some sections in an instance translate "yes" or "no"): add the its:info element as the first child element of these sections in the instance. If a schema exists, add it also to the content model of the element as an optional element.
<myns:myFile xmlns:its="http://example.com/its" xmlns:myns="http://example.com/mysn"> <its:info> <its:translate translatability="yes"/> </its:info> <myns:myElement> <its:info> <its:translate translatability="no"/> </its:info>This is a piece of text.</myns:myElement> <myns:myElement>This is another piece of text.</myns:myElement> <myns:myElement myAttr="This is yet another piece of text."> </myns:myElement> </myns:myFile>
Task 5 (for a specific attribute in general translate "yes" or "no"): add the its:info element to the xs:annotation element of the element to which the attribute belongs to in the schema. Use the scopedAttribute attribute to specify the attribute, and restrict the value of the translatability attribute to "yes" or "no".
<xs:element name="myElement">
<xs:annotation>
<xs:appinfo>
<its:info scopedAttribute="myAttr">
<its:translate translatability="yes"/>
</its:info>
</xs:appinfo>
</xs:annotation>
<xs:complexType mixed="true">
<xs:attribute name="myAttr" type="xs:string" use="optional"/>
</xs:complexType>
</xs:element>
Task 6 (for a specific attribute in a doc translate "yes" or "no"): add the its:info element as the first child of the element to which the attribute belongs to in the instance, and use the scopedAttribute attribute to specify the attribute.
<myns:myElement myAttr="This is yet another piece of text.">
<its:info scopedAttribute="myAttr">
<its:translate translatability="yes"/>
</its:info>This is some element content.
</myns:myElement>
Task 7 (extension for somebody in the schema / instance): add the its:info element with an its:extension child to the schema (if a schema exists). Use it as the first child of the element in the instance.
<myns:myFile xmlns:its="http://example.com/its"
xmlns:myns="http://example.com/mysn">
<its:info>
<its:extension>
<anythingForAnybody/>
</its:extension>
</its:info>This is some element content.
<myns:myElement>
Task 8 (allow ruby for element / attribute content): add the its:info element as the first child element of the element in the instance. If a schema exists, add it also to the content model of the element as an optional element. If the scope is an attribute, use the scopedAttribute attribute to specify that attribute.
<myns:myElement>
<its:info>
<its:ruby>
<its:rb>This is a base text.</its:rb>
<its:rt>This is a ruby annotation</its:rt>
</its:ruby>
</its:info>
This is a base text.
</myns:myElement>
<xs:element name="myElement">
<xs:complexType>
<xs:sequence>
<xs:element ref="its:info" minOccurs="0"/>
<xs:element ref="myns:myElement" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<myns:myElement myAttr="This is a base text in an attribute.">
<its:info scopedAttribute="myAttr">
<its:ruby>
<its:rb>This is a base text in an attribute.</its:rb>
<its:rt>This is a ruby annotation</its:rt>
</its:ruby>
</its:info>
This is a base text.
</myns:myElement>
Task 9 (add its specific information to textual content): Use an its:span element to markup the textual content. The content of its:span will be an its:info element.
<myns:myElement>
This is some <its:span><its:info>...</its:info>special</its:span> text</myns:myElement>.
This Schema encompasses also declarations for Ruby. They are only to be used in the document istance, i.e. they fulfil tasks 4 and 6. TODO: add the its:span element. The schema is made in a way that it can be converted to XML DTDs or RELAX NG.
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:its="http://example.com/its" targetNamespace="http://example.com/its" elementFormDefault="qualified"> <xs:attributeGroup name="generalAttr"> <xs:attribute name="scopedAttribute" type="xs:QName" use="optional"/> </xs:attributeGroup> <xs:element name="infos"> <xs:complexType> <xs:sequence maxOccurs="unbounded"> <xs:element ref="its:info" maxOccurs="unbounded"/> </xs:sequence> <xs:attributeGroup ref="its:generalAttr"/> </xs:complexType> </xs:element> <xs:element name="info"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element ref="its:ruby"/> <xs:element ref="its:translate"/> <xs:element ref="its:extension"/> </xs:choice> <xs:attributeGroup ref="its:generalAttr"/> </xs:complexType> </xs:element> <xs:element name="ruby"> <xs:complexType> <xs:choice> <xs:sequence> <xs:element ref="its:rb"/> <xs:choice> <xs:element ref="its:rt"/> <xs:sequence> <xs:element ref="its:rp"/> <xs:element ref="its:rt"/> <xs:element ref="its:rp"/> </xs:sequence> </xs:choice> </xs:sequence> <xs:sequence> <xs:element ref="its:rbc"/> <xs:element ref="its:rtc"/> <xs:element ref="its:rtc" minOccurs="0"/> </xs:sequence> </xs:choice> <xs:attributeGroup ref="its:generalAttr"/> </xs:complexType> </xs:element> <xs:element name="rbc"> <xs:complexType> <xs:sequence> <xs:element ref="its:rb" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="rtc"> <xs:complexType> <xs:sequence> <xs:element ref="its:rt" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="rb" type="xs:string"/> <xs:element name="rt" type="xs:string"/> <xs:element name="rp" type="xs:string"/> <xs:element name="translate"> <xs:complexType> <xs:attribute name="translatability"> <xs:simpleType> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="yes"/> <xs:enumeration value="no"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:attributeGroup ref="its:generalAttr"/> </xs:complexType> </xs:element> <xs:element name="extension"> <xs:complexType> <xs:sequence> <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attributeGroup ref="its:generalAttr"/> </xs:complexType> </xs:element> </xs:schema>