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

attribute is missing #25

Closed
kk-wdt opened this issue Jul 29, 2020 · 14 comments
Closed

attribute is missing #25

kk-wdt opened this issue Jul 29, 2020 · 14 comments

Comments

@kk-wdt
Copy link

kk-wdt commented Jul 29, 2020

<xsd:element name="AgeRecommendation">
xsd:complexType
xsd:sequence
<xsd:element name="MinimumManufacturerAgeRecommended" type="MinimumAgeRecommendedDimension" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:complexType name="MinimumAgeRecommendedDimension">
xsd:simpleContent
<xsd:extension base="xsd:nonNegativeInteger">
<xsd:attribute name="unitOfMeasure" type="AgeRecommendedUnitOfMeasure" use="required"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>

<xsd:simpleType name="AgeRecommendedUnitOfMeasure">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="months"/>
<xsd:enumeration value="years"/>
</xsd:restriction>
</xsd:simpleType>

i can not find the attribute name "unitOfMeasure" in this case

@kk-wdt
Copy link
Author

kk-wdt commented Jul 29, 2020

@lcduarte

@lcduarte
Copy link
Member

lcduarte commented Jul 29, 2020

Hello,

I've tested with that XSD and somehow the attribute is not present in the XsdExtension element. I'll need some time to understand the issue, I'll probably get back to you on the weekend.

Edit: At first glance it seems that the DOM library that I'm using to convert the XSD to a list of nodes isn't parsing that element somehow, it's weird.

@kk-wdt
Copy link
Author

kk-wdt commented Jul 30, 2020

btw... the element "MinimumManufacturerAgeRecommended" is also missing when it is a base xsd
eg:
<xsd:include schemaLocation="base.xsd"/>
<xsd:element ref="AgeRecommendation" minOccurs="0"/>

@lcduarte
Copy link
Member

Can you send the xsd files that you are using so I can reproduce the issue more accurately?

@lcduarte
Copy link
Member

I found the problem and I've solved both situations reported. I'm trying to perform a new release but I'm getting some kind of timeout at the moment. I'll try it later and inform you.

@kk-wdt
Copy link
Author

kk-wdt commented Jul 30, 2020

thanks for the fast response!
waiting for the new release

@kk-wdt
Copy link
Author

kk-wdt commented Jul 30, 2020

hello
can you give me a demo about how to deal with ref attribute ,it seems like not a correct type of UnsolvedReference in the wiki
here is XSD files and the ref element named "BeautyMisc"
https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_1_9/Books.xsd

@lcduarte
Copy link
Member

I think my deployment "failed" but the new version is already deployed, (1.0.30).

Simply put, the XsdParser has two different iterations. The first iteration goes through all the xsd element nodes and either converts them into a ConcreteElement/NamedConcreteElement or UnsolvedReference.

  • ConcreteElements are elements which don't have a name attribute, nor a ref attribute.
  • NamedConcreteElements are elements which have a name attribute.
  • UnsolvedReferences are elements which have the ref attribute.

In the second iteration the Parser goes through all the UnsolvedReferences and tries to find the corresponding NamedConcreteElement. In concrete terms it tries to find the xsd element with the same name as the name present in the ref attribute of another element.

When a ConcreteElement matches with a UnsolvedReference the UnsolvedReference object is replaced by a clone of the original ConcreteElement. In the latest version I improved the cloning process which resulted in the bugs reported in this issue.

Any UnsolvedReferences present after the parsing process means that the Parser couldn't find the element with the name attribute with the same value as the ref attribute of the element wrapped in the UnsolvedReference object.

Either that or something is wrong with the Parser 😄

@kk-wdt
Copy link
Author

kk-wdt commented Jul 31, 2020

i found another problem when parsing the element path "AutoAccessory/ProductType/AutoAccessoryMisc/Amperage".
the element of Amperage is exist, but after parsed its type is ' UnsolvedReference'
here is the xsd file
https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/xsd/release_4_1/AutoAccessory.xsd
@lcduarte

@lcduarte
Copy link
Member

I've investigated the issue and it looks like the problem is due to it being a "second degree" reference.

This means that since the AutoAccessoryMisc is referenced on Product Type and then the AutoAccessoryMisc itself has its own "references" such as the type AmperageDimension the second level reference won't be resolved.

I'll need some time to solve this.

@lfrancke
Copy link

lfrancke commented Sep 7, 2020

It looks like I'm hitting the same issue with 1.0.32.
I tried with this example XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://foo" xmlns="http://foo" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="A" type="AType"/>
  <xs:complexType name="AType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="AttributeA" type="xs:string" use="optional"/>
        <xs:attribute name="AttributeB" type="xs:string" use="optional"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:schema>

I cannot find a way to get to those attributes.

@lcduarte
Copy link
Member

Hello,

First, sorry for taking so long solving this one @hehengkaifj , it really was a tough one. Like I said before XsdParser was only solving first degree references, for example:

<xsd:element name="A" ref="B"/>

<xsd:element name="B" ref="C"/>

<xsd:element name="C"/>

In this case XsdParser would be able to resolve both references.

  • Element A would have a clone of B;
  • Element B would have a clone of C;

But, the B clone that element A had wouldn't have the reference resolved with element C.

This behavior was solved by adding the unsolved references of the clone in the Parser Reference Solving process. This way all clones should have be similar and have the same references solved.

I released a new version, (1.1.0), with these changes, hopefully those solve your issues!

If possible give me some feedback.

@lfrancke
Copy link

lfrancke commented Oct 5, 2020

I tried this one out on my code and I'm able to get the attributes from my earlier example. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants