You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:elementname="model.respLike"abstract="true"/>
...
<!-- the reference to abstract element is used on several places -->
<xs:groupname="model.biblPart">
<xs:choice>
<xs:elementref="ns1:model.respLike"/>
<xs:elementref="ns1:model.imprintPart"/>
<xs:elementref="ns1:series"/>
<xs:elementref="ns1:meeting"/>
<xs:elementref="ns1:relatedItem"/>
<xs:elementref="ns1:edition"/>
<xs:elementref="ns1:extent"/>
<xs:elementref="ns1:idno"/>
</xs:choice>
</xs:group>
...
<!-- element derived from abstract element and extended -->
<xs:elementname="author"substitutionGroup="ns1:model.respLike">
<xs:complexType>
<xs:complexContent>
<xs:extensionbase="ns1:macro.phraseSeq">
<xs:attributeGroupref="ns1:att.global.attributes"/>
<xs:attributeGroupref="ns1:att.canonical.attributes"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
...
<!-- abstract element used to define a complexType -->
<xs:elementname="titleStmt">
<xs:complexType>
<xs:sequence>
<xs:elementmaxOccurs="unbounded"ref="ns1:title"/>
<xs:elementminOccurs="0"maxOccurs="unbounded"ref="ns1:model.respLike"/>
</xs:sequence>
<xs:attributeGroupref="ns1:att.global.attributes"/>
</xs:complexType>
</xs:element>
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){varelementsArray=this.objectType.elements;if(elementsArray){for(vari=0;i<elementsArray.length;i++){varprefix=this.editor.xmlState.getNamespacePrefix(elementsArray[i].namespace);if(prefix+elementsArray[i].localName==childNode.nodeName){//console.log("With def.: ", childNode); //KhamylvarchildElement=newXMLElement($(childNode),elementsArray[i],this.editor);childElement.render(this,recursive);this.addChildrenCount(childElement);return;}}}// Handle children that do not have a definitionvarchildElement=newXMLUnspecifiedElement($(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)
The text was updated successfully, but these errors were encountered:
@khamyl
Would you be able to share the error message that you receive from the console?
There are a number of test cases and schemas in this project that include abstract elements (for example schema_sub.xsd and dc.xsd).
Type references are supposed to be applied to element definitions, for example here in the schema_processor. Similarly, abstract elements are supposed to be excluded from appearing as children of other elements here.
It may not currently be able to handle an abstract element definition being referenced as the child of another element, such as in titleStmt. I haven't tested this in a while, but based on skimming the implementation I would think that that child wouldn't show up at all, since I don't think the editor attempts to determine what subclasses of a definition inherit from an abstract reference like this.
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.js
script 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
)The text was updated successfully, but these errors were encountered: