Repository: tefra/xsdata
Pull request #432 (2021-03-24 18:45:19)

ElementMapper fix attribute type detection
Notes:
- QName converter remove {uri}name format parsing
- Remove QName from inferable types, this really
  neads ncname validation to work

sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL)

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432) No Coverage information  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list)


codecov[bot]: # [Codecov](https://codecov.io/gh/tefra/xsdata/pull/432?src=pr&el=h1) Report
> Merging [#432](https://codecov.io/gh/tefra/xsdata/pull/432?src=pr&el=desc) (3eca3fb) into [master](https://codecov.io/gh/tefra/xsdata/commit/308acb8d3b74e5e694676ad7d52624f2b03972cc?el=desc) (308acb8) will **decrease** coverage by `0.05%`.
> The diff coverage is `92.00%`.

[![Impacted file tree graph](https://codecov.io/gh/tefra/xsdata/pull/432/graphs/tree.svg?width=650&height=150&src=pr&token=YzDDLtywvl)](https://codecov.io/gh/tefra/xsdata/pull/432?src=pr&el=tree)

```diff
@@             Coverage Diff             @@
##            master     #432      +/-   ##
===========================================
- Coverage   100.00%   99.94%   -0.06%     
===========================================
  Files           74       74              
  Lines         6878     6878              
  Branches      1216     1213       -3     
===========================================
- Hits          6878     6874       -4     
- Misses           0        2       +2     
- Partials         0        2       +2     
```


| [Impacted Files](https://codecov.io/gh/tefra/xsdata/pull/432?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [xsdata/codegen/mappers/element.py](https://codecov.io/gh/tefra/xsdata/pull/432/diff?src=pr&el=tree#diff-eHNkYXRhL2NvZGVnZW4vbWFwcGVycy9lbGVtZW50LnB5) | `98.56% <88.23%> (-1.44%)` | :arrow_down: |
| [xsdata/formats/converter.py](https://codecov.io/gh/tefra/xsdata/pull/432/diff?src=pr&el=tree#diff-eHNkYXRhL2Zvcm1hdHMvY29udmVydGVyLnB5) | `99.30% <100.00%> (-0.70%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/tefra/xsdata/pull/432?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/tefra/xsdata/pull/432?src=pr&el=footer). Last update [308acb8...3eca3fb](https://codecov.io/gh/tefra/xsdata/pull/432?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL)

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432) No Coverage information  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list)


sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL)

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432) No Coverage information  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list)


sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL)

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432) No Coverage information  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list)


sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL)

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432) No Coverage information  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list)


sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL)

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432) No Coverage information  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list)


sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug.png' alt='Bug' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=BUG)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability.png' alt='Vulnerability' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=VULNERABILITY)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot.png' alt='Security Hotspot' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=tefra_xsdata&pullRequest=432&resolved=false&types=SECURITY_HOTSPOT)  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell.png' alt='Code Smell' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A.png' alt='A' width='16' height='16' />](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=tefra_xsdata&pullRequest=432&resolved=false&types=CODE_SMELL)

[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo.png' alt='No Coverage information' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432) No Coverage information  
[<img src='https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3.png' alt='0.0%' width='16' height='16' />](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=tefra_xsdata&pullRequest=432&metric=new_duplicated_lines_density&view=list)



Patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 039a18dd..e0b297f6 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -2,7 +2,7 @@ exclude: tests/fixtures|docs/examples
 
 repos:
   - repo: https://github.com/asottile/pyupgrade
-    rev: v2.10.0
+    rev: v2.11.0
     hooks:
       - id: pyupgrade
         args: [--py37-plus]
diff --git a/xsdata/codegen/mappers/element.py b/xsdata/codegen/mappers/element.py
index a08bb741..ad3aab3e 100644
--- a/xsdata/codegen/mappers/element.py
+++ b/xsdata/codegen/mappers/element.py
@@ -1,6 +1,5 @@
 import sys
 from collections import defaultdict
-from dataclasses import dataclass
 from typing import Any
 from typing import Iterator
 from typing import List
@@ -13,13 +12,13 @@ from xsdata.codegen.models import Class
 from xsdata.formats.converter import converter
 from xsdata.formats.dataclass.models.generics import AnyElement
 from xsdata.models.enums import DataType
+from xsdata.models.enums import QNames
 from xsdata.models.enums import Tag
 from xsdata.utils import collections
 from xsdata.utils.namespaces import build_qname
 from xsdata.utils.namespaces import split_qname
 
 
-@dataclass
 class ElementMapper:
     """Map a schema instance to classes, extensions and attributes."""
 
@@ -79,8 +78,8 @@ class ElementMapper:
         children = [c for c in element.children if isinstance(c, AnyElement)]
         sequential_set = cls.sequential_names(children)
 
-        for key, _ in element.attributes.items():
-            attr_type = AttrType(qname=str(DataType.STRING), native=True)
+        for key, value in element.attributes.items():
+            attr_type = cls.build_attribute_type(key, value)
             cls.build_attribute(target, key, attr_type, target_namespace, Tag.ATTRIBUTE)
 
         for child in children:
@@ -93,9 +92,11 @@ class ElementMapper:
             inner = None
             if child.attributes or child.children:
                 inner = cls.build_class(child, target_namespace)
+                attr_type = AttrType(qname=inner.qname, forward=True)
                 target.inner.append(inner)
+            else:
+                attr_type = cls.build_attribute_type(child.qname, child.text)
 
-            attr_type = cls.build_attribute_type(child.text, inner)
             cls.build_attribute(
                 target,
                 child.qname,
@@ -106,23 +107,29 @@ class ElementMapper:
             )
 
         if element.text:
-            attr_type = AttrType(qname=str(DataType.STRING), native=True)
+            attr_type = cls.build_attribute_type("value", element.text)
             cls.build_attribute(target, "value", attr_type, None, Tag.SIMPLE_TYPE)
 
         return target
 
     @classmethod
-    def build_attribute_type(cls, text: Any, inner: Optional[Class]) -> AttrType:
-        if inner:
-            return AttrType(qname=inner.qname, forward=True)
+    def build_attribute_type(cls, qname: str, value: Any) -> AttrType:
+        def match_type(val: Any) -> DataType:
+            if not isinstance(val, str) or val == "":
+                return DataType.ANY_SIMPLE_TYPE
 
-        if text:
-            for tp in converter.sorted_types():
-                if converter.test(text, [tp], require_namespace=True):
-                    data_type = DataType.from_type(tp)
-                    return AttrType(qname=str(data_type), native=True)
+            for tp in converter.explicit_types():
+                if converter.test(val, [tp]):
+                    return DataType.from_type(tp)
 
-        return AttrType(qname=str(DataType.ANY_SIMPLE_TYPE), native=True)
+            return DataType.STRING
+
+        if qname == QNames.XSI_TYPE:
+            data_type = DataType.QNAME
+        else:
+            data_type = match_type(value)
+
+        return AttrType(qname=str(data_type), native=True)
 
     @classmethod
     def build_attribute(
@@ -177,7 +184,7 @@ class ElementMapper:
 
             if not existing:
                 target.attrs.append(attr)
-            elif not (attr.is_attribute or attr.is_enumeration):
+            else:
                 min_occurs = existing.restrictions.min_occurs or 0
                 max_occurs = existing.restrictions.max_occurs or 1
                 attr_min_occurs = attr.restrictions.min_occurs or 0
diff --git a/xsdata/formats/converter.py b/xsdata/formats/converter.py
index c078b958..a73bcafb 100644
--- a/xsdata/formats/converter.py
+++ b/xsdata/formats/converter.py
@@ -104,18 +104,15 @@ class ConverterFactory:
         instance = self.value_converter(value)
         return instance.serialize(value, **kwargs)
 
-    def test(self, value: Any, types: List[Type], **kwargs: Any) -> bool:
+    def test(self, value: Optional[str], types: List[Type], **kwargs: Any) -> bool:
         """
         Test the given string value can be parsed using the given list of types
         without warnings.
 
-        In case of float/int types also very the roundtrip conversion
-        result still matches the original input.
+        For certain types also validate roundtrip conversion matches
+        original value.
         """
 
-        if isinstance(value, tuple(types)):
-            return True
-
         if not isinstance(value, str):
             return False
 
@@ -187,8 +184,8 @@ class ConverterFactory:
         return sorted(types, key=lambda x: __PYTHON_TYPES_SORTED__.get(x, 0))
 
     @classmethod
-    def sorted_types(cls) -> Dict:
-        return __PYTHON_TYPES_SORTED__
+    def explicit_types(cls) -> Tuple:
+        return __EXPLICIT_TYPES__
 
 
 __PYTHON_TYPES_SORTED__ = {
@@ -208,6 +205,18 @@ __PYTHON_TYPES_SORTED__ = {
     str: 14,
 }
 
+__EXPLICIT_TYPES__ = (
+    int,
+    bool,
+    float,
+    Decimal,
+    XmlTime,
+    XmlDate,
+    XmlDateTime,
+    XmlDuration,
+    XmlPeriod,
+)
+
 
 class BoolConverter(Converter):
     def deserialize(self, value: Any, **kwargs: Any) -> bool:
@@ -312,7 +321,6 @@ class QNameConverter(Converter):
         self,
         value: str,
         ns_map: Optional[Dict] = None,
-        require_namespace: bool = False,
         **kwargs: Any,
     ) -> QName:
         """
@@ -326,7 +334,7 @@ class QNameConverter(Converter):
         self.validate_input_type(value, str)
         namespace, tag = self.resolve(value, ns_map)
 
-        if " " in tag or (not namespace and require_namespace):
+        if " " in tag:
             raise ConverterError()
 
         return QName(namespace, tag) if namespace else QName(tag)
@@ -360,19 +368,13 @@ class QNameConverter(Converter):
     def resolve(value: str, ns_map: Optional[Dict]) -> Tuple:
         value = value.strip()
 
-        if not value:
-            raise ConverterError("Value is empty")
-
-        if value[0] == "{":
-            namespace, name = text.split(value[1:], "}")
+        if not value or value[0] == "{":
+            raise ConverterError()
 
-            if not namespace:
-                raise ConverterError("Value is not a QName")
-        else:
-            prefix, name = text.split(value, ":")
-            namespace = ns_map.get(prefix) if ns_map else None
-            if prefix and not namespace:
-                raise ConverterError(f"Unknown namespace prefix: `{prefix}`")
+        prefix, name = text.split(value, ":")
+        namespace = ns_map.get(prefix) if ns_map else None
+        if prefix and not namespace:
+            raise ConverterError(f"Unknown namespace prefix: `{prefix}`")
 
         return namespace, name
 


Test patch:
diff --git a/tests/codegen/mappers/test_element.py b/tests/codegen/mappers/test_element.py
index 8e0fcfef..fd72203b 100644
--- a/tests/codegen/mappers/test_element.py
+++ b/tests/codegen/mappers/test_element.py
@@ -5,6 +5,7 @@ from unittest import mock
 from xsdata.codegen.mappers.element import ElementMapper
 from xsdata.formats.dataclass.models.generics import AnyElement
 from xsdata.models.enums import DataType
+from xsdata.models.enums import QNames
 from xsdata.models.enums import Tag
 from xsdata.utils.testing import AttrFactory
 from xsdata.utils.testing import AttrTypeFactory
@@ -75,8 +76,8 @@ class ElementMapperTests(FactoryTestCase):
     def test_build_class_simple_type(self):
         element = AnyElement(
             qname="{xsdata}root",
-            attributes={"{foo}bar": "1", "{bar}foo": "2"},
-            text="thugLife",
+            attributes={"{foo}bar": "1", "{bar}foo": "2.0"},
+            text="true",
         )
 
         actual = ElementMapper.build_class(element, "target")
@@ -88,21 +89,21 @@ class ElementMapperTests(FactoryTestCase):
             ns_map={},
             attrs=[
                 AttrFactory.native(
-                    DataType.STRING,
+                    DataType.INT,
                     tag=Tag.ATTRIBUTE,
                     name="bar",
                     namespace="foo",
                     index=0,
                 ),
                 AttrFactory.native(
-                    DataType.STRING,
+                    DataType.FLOAT,
                     tag=Tag.ATTRIBUTE,
                     name="foo",
                     namespace="bar",
                     index=1,
                 ),
                 AttrFactory.native(
-                    DataType.STRING,
+                    DataType.BOOLEAN,
                     tag=Tag.SIMPLE_TYPE,
                     name="value",
                     namespace=None,
@@ -178,28 +179,26 @@ class ElementMapperTests(FactoryTestCase):
         self.assertEqual(expected, actual)
 
     def test_build_attribute_type(self):
-        inner = ClassFactory.create()
-
-        actual = ElementMapper.build_attribute_type(None, inner)
-        self.assertEqual(inner.qname, actual.qname)
-        self.assertTrue(actual.forward)
+        actual = ElementMapper.build_attribute_type(QNames.XSI_TYPE, "")
+        self.assertEqual(str(DataType.QNAME), actual.qname)
+        self.assertTrue(actual.native)
 
-        actual = ElementMapper.build_attribute_type("foo", None)
+        actual = ElementMapper.build_attribute_type("name", "foo")
         self.assertEqual(str(DataType.STRING), actual.qname)
         self.assertTrue(actual.native)
 
-        actual = ElementMapper.build_attribute_type("", None)
+        actual = ElementMapper.build_attribute_type("name", "")
         self.assertEqual(str(DataType.ANY_SIMPLE_TYPE), actual.qname)
         self.assertTrue(actual.native)
 
-        actual = ElementMapper.build_attribute_type(None, None)
+        actual = ElementMapper.build_attribute_type("name", None)
         self.assertEqual(str(DataType.ANY_SIMPLE_TYPE), actual.qname)
         self.assertTrue(actual.native)
 
         class A:
             pass
 
-        actual = ElementMapper.build_attribute_type(A(), None)
+        actual = ElementMapper.build_attribute_type("name", A())
         self.assertEqual(str(DataType.ANY_SIMPLE_TYPE), actual.qname)
         self.assertTrue(actual.native)
 
@@ -248,8 +247,8 @@ class ElementMapperTests(FactoryTestCase):
         ElementMapper.merge_attributes(target, source)
 
         names = ["id", "b", "c", "d", "a"]
-        min_occurs = [None, 0, 0, None, 0]
-        max_occurs = [None, 4, 1, None, 3]
+        min_occurs = [0, 0, 0, None, 0]
+        max_occurs = [4, 4, 1, None, 3]
 
         self.assertEqual(names, [x.name for x in target.attrs])
         self.assertEqual(min_occurs, [x.restrictions.min_occurs for x in target.attrs])
diff --git a/tests/fixtures/artists/metadata.py b/tests/fixtures/artists/metadata.py
index 7fbf678f..26e249d2 100644
--- a/tests/fixtures/artists/metadata.py
+++ b/tests/fixtures/artists/metadata.py
@@ -188,7 +188,7 @@ class AliasList:
         name = "alias-list"
         namespace = "http://musicbrainz.org/ns/mmd-2.0#"
 
-    count: Optional[str] = field(
+    count: Optional[int] = field(
         default=None,
         metadata={
             "type": "Attribute",
diff --git a/tests/formats/test_converter.py b/tests/formats/test_converter.py
index 85626e49..f3b737a2 100644
--- a/tests/formats/test_converter.py
+++ b/tests/formats/test_converter.py
@@ -42,8 +42,8 @@ class ConverterFactoryTests(TestCase):
         self.assertEqual("8.77683E-08", converter.serialize(float("8.77683E-8")))
 
     def test_test(self):
-        self.assertTrue(converter.test(1, [int]))
-        self.assertFalse(converter.test(1, [float]))
+        self.assertTrue(converter.test("1", [int]))
+        self.assertFalse(converter.test("1", [float]))
         self.assertFalse(converter.test(None, [int]))
 
         self.assertFalse(converter.test("a", [int]))
@@ -54,9 +54,6 @@ class ConverterFactoryTests(TestCase):
         self.assertFalse(converter.test(".0", [float]))
         self.assertTrue(converter.test("1.0", [float]))
 
-        self.assertTrue(converter.test("{a}b", [QName]))
-        self.assertFalse(converter.test("{ab", [QName]))
-
     def test_unknown_converter(self):
         class A:
             pass
@@ -304,6 +301,7 @@ class QNameConverterTests(TestCase):
 
     def test_deserialize(self):
         convert = self.converter.deserialize
+
         with self.assertRaises(ConverterError) as cm:
             convert("a:b")
         self.assertEqual("Unknown namespace prefix: `a`", str(cm.exception))
@@ -312,17 +310,17 @@ class QNameConverterTests(TestCase):
             convert("a:b", ns_map={})
         self.assertEqual("Unknown namespace prefix: `a`", str(cm.exception))
 
-        with self.assertRaises(ConverterError) as cm:
+        with self.assertRaises(ConverterError):
             convert("", ns_map={})
-        self.assertEqual("Value is empty", str(cm.exception))
 
-        with self.assertRaises(ConverterError) as cm:
-            convert("{a b")
-        self.assertEqual("Value is not a QName", str(cm.exception))
+        with self.assertRaises(ConverterError):
+            convert("{a}b", ns_map={})
+
+        with self.assertRaises(ConverterError):
+            convert("a a")
 
         self.assertEqual(QName("a"), convert("a", ns_map={}))
         self.assertEqual(QName("aa", "b"), convert("a:b", ns_map={"a": "aa"}))
-        self.assertEqual(QName("{a}b"), convert("{a}b"))
 
     def test_serialize(self):
         ns_map = {"c_prefix": "c"}