Problem description
Is the editor dealing with abstract elements?
I have a quite complex XSD. I'll focus only to the problematic part of it.
The XML Schema
<?xml version="1.0" encoding="UTF-8"?>
...
<xs:schema>
...
<!-- the definition of abstract element-->
<xs:element name="model.respLike" abstract="true"/>
...
<!-- the reference to abstract element is used on several places -->
<xs:group name="model.biblPart">
<xs:choice>
<xs:element ref="ns1:model.respLike"/>
<xs:element ref="ns1:model.imprintPart"/>
<xs:element ref="ns1:series"/>
<xs:element ref="ns1:meeting"/>
<xs:element ref="ns1:relatedItem"/>
<xs:element ref="ns1:edition"/>
<xs:element ref="ns1:extent"/>
<xs:element ref="ns1:idno"/>
</xs:choice>
</xs:group>
...
<!-- element derived from abstract element and extended -->
<xs:element name="author" substitutionGroup="ns1:model.respLike">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ns1:macro.phraseSeq">
<xs:attributeGroup ref="ns1:att.global.attributes"/>
<xs:attributeGroup ref="ns1:att.canonical.attributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
...
<!-- abstract element used to define a complexType -->
<xs:element name="titleStmt">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="ns1:title"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="ns1:model.respLike"/>
</xs:sequence>
<xs:attributeGroup ref="ns1:att.global.attributes"/>
</xs:complexType>
</xs:element>
The XML instance
...
<titleStmt>
<title>Přemyšlování o dokonalosti křesťanské</title>
<author>Jan Amos Komenský</author>
</titleStmt>
...
In the JSON generated by xsd2json.js script the <titleStmt> element 2. child is referring to the abstract element. As a result the renderChild() function is handling the <author> element as "without the defiition":
XMLElement.prototype.renderChild = function(childNode, recursive) {
var elementsArray = this.objectType.elements;
if (elementsArray) {
for ( var i = 0; i < elementsArray.length; i++) {
var prefix = this.editor.xmlState.getNamespacePrefix(elementsArray[i].namespace);
if (prefix + elementsArray[i].localName == childNode.nodeName) {
//console.log("With def.: ", childNode); //Khamyl
var childElement = new XMLElement($(childNode), elementsArray[i], this.editor);
childElement.render(this, recursive);
this.addChildrenCount(childElement);
return;
}
}
}
// Handle children that do not have a definition
var childElement = new XMLUnspecifiedElement($(childNode), this.editor);
childElement.render(this, recursive);
this.addChildrenCount(childElement);
};
The questions are
- Are the abstract elements supported?
- If not, where you suggest to implment it
- in schema generator (
xsd2json.js)
- in xml editor (
xml_element.js)
Problem description
Is the editor dealing with abstract elements?
I have a quite complex XSD. I'll focus only to the problematic part of it.
The XML Schema
The XML instance
In the JSON generated by
xsd2json.jsscript the<titleStmt>element 2. child is referring to the abstract element. As a result therenderChild()function is handling the<author>element as "without the defiition":The questions are
xsd2json.js)xml_element.js)