Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xml-parser-ts Doesn't manage Complex Types with Simple Content #665

Closed
Tracked by #453
yesamer opened this issue Oct 31, 2023 · 1 comment · Fixed by apache/incubator-kie-tools#2039
Closed
Tracked by #453
Assignees
Labels
area:test-scenario Related to Test Scenario (scesim) area:tools Issues affecting Apache KIE tooling projects type:enhancement Something that already exists needs to be improved

Comments

@yesamer
Copy link

yesamer commented Oct 31, 2023

xml-parser-ts it's not able to manage Complex Types with Simple Content, please consider the following example:

XML
<rawValue class="string">Above speed limit: 10km/h and 30 km/h</rawValue>

XSD

<xsd:complexType name="rawValueType">
    <xsd:simpleContent>
      <xsd:extension base="xsd:string">
        <xsd:attribute type="xsd:string" name="class" />
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>

Current generated type:

export type SceSim__rawValueType =   {

}

Fields are missing

At Runtime:

rawValue: 
@_class: "string"

Only the attribute is correctly parsed

@yesamer yesamer added type:enhancement Something that already exists needs to be improved area:tools Issues affecting Apache KIE tooling projects area:test-scenario Related to Test Scenario (scesim) labels Oct 31, 2023
@yesamer yesamer self-assigned this Oct 31, 2023
@tiagobento
Copy link

Right, right. Good catch. I don't think DMN nor BPMN have this use-case, but yeah, indeed a flaw on xml-parser-ts that needs to be addressed. We'll have to introduce a convention for this, which I'm not a big fan of, but I don't see any other way. Text content will have to be given its own attribute (always), and we'll need to add special treatment for it on the build function of xml-parser-ts too.

In the example you share, we'll need to generate a type

export type SceSim__rawValueType = {
  "__$$text": string;
  "@_class": string;
}

Note that __$$text follows the same absurdity as the __$$element property we already have for resolving substitution groups.

This is not a very complicated change, but definitely will impact everyone using xml-parser-ts right now, as it will introduce breaking changes, for example, to typeRefs on DMN.

@yesamer How urgent is this for

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:test-scenario Related to Test Scenario (scesim) area:tools Issues affecting Apache KIE tooling projects type:enhancement Something that already exists needs to be improved
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants