SAA-SDT / EAD3

https://www.loc.gov/ead/index.html
Creative Commons Zero v1.0 Universal
80 stars 25 forks source link

Element and attribute has same name! #515

Closed smartKaisar closed 5 years ago

smartKaisar commented 6 years ago
<xs:complexType name="languagedeclaration"><xs:sequence>
        <xs:element name="language" type="language"/>
        <xs:element name="script" type="script"/>
        <xs:element name="descriptivenote" type="descriptivenote" minOccurs="0"/>
</xs:sequence><xs:attributeGroup ref="am.common"/><xs:attribute name="encodinganalog" type="xs:token"/></xs:complexType>

attribute group am.common contains attribute with name script which is being used in multiple elements and some element like languagedeclaration contains another element with name script.

<xs:attributeGroup name="am.common">
    <xs:attributeGroup ref="am.common.empty"/>
    <xs:attribute name="lang" type="xs:NMTOKEN"/>
    <xs:attribute name="script" type="xs:NMTOKEN"/>
</xs:attributeGroup>

When we are using code generation tools which is intended to generate code form xsd (for example jaxb) it can't have two variable with same name. Hence replacing the element with scriptType which is difficult to imagine in terms of contextual traverse of the xml elements.

Way around could be looking into the generated code manually. Any other suggestions?

regineheberlein commented 6 years ago

Alas, nothing other than manual intervention comes to mind. Perhaps @tcatapano knows of a workaround?

fordmadox commented 6 years ago

@smartKaisar : can you report this issue to the JAXB community if you haven't already?

If I understand correctly, then it should be something that could be handled by that tool. There's no XML restriction that prohibits elements and attributes from sharing the same name, so I wouldn't say that this an EAD3-only issue for JAXB. And I'd assume it would be something that JAXB would want to be able to handle: attributes are different node types in XML, and in this case the script element and script attribute are also in different namespaces, so they should be able to be distinguished.

For what it's worth, I used the oXygen XML Editor to generate a sample EAD3 document from its XSD schema, and it did not have any issues in creating that file in regards to script and @script. Here's a sample piece of output:

<script id="ID123" altrender="altrender123" audience="external" lang="lang121" script="script121" encodinganalog="encodinganalog85" label="label13" scriptcode="scriptcode3"></script>

All that said, I do think that this (e.g. using the same name for an element and attribute) is something that the EAD3 community should consider. I wasn't part of the EAD3 development process, though, so I don't know the rationale behind using that name as both an element and an attribute.

noahgh221 commented 5 years ago

Long overdue follow up to this issue...

TS-EAD discussed this issue in our 2018-03-26 meeting. There was a general sense that this is a relatively isolated issue specific to JAXB. Modifying the EAD schema to solve this particular problem would have consequences for the larger EAD community that outweigh the benefit of solving this particular reported JAXB issue.

Still, TS-EAD should keep this issue in mind during future major revisions or when adding any future elements and attributes to the schema. It seems like a good general principle to avoid duplication of element and attribute names.

Closing this issue.