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

lxml.etree.XPathEvalError: Undefined namespace prefix #82

Closed
slamer59 opened this issue Nov 25, 2021 · 3 comments
Closed

lxml.etree.XPathEvalError: Undefined namespace prefix #82

slamer59 opened this issue Nov 25, 2021 · 3 comments

Comments

@slamer59
Copy link

Hello,
I want to make a diff with an archimate model (XML)

I have the following error

First model:

<?xml version="1.0" encoding="UTF-8"?>
<archimate:model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:archimate="http://www.archimatetool.com/archimate" name="model_indep_1" id="id-1c8620d7bba6422daa2c194868f32e10" version="4.9.0">
  <folder name="Strategy" id="id-0701c8ef4dcc406488089b1540f80e60" type="strategy">
    <element xsi:type="archimate:Resource" name="Resource_1" id="id-2dc7c45e2dd740eb8a72c5726c13a748"/>
  </folder>
  <folder name="Business" id="id-3987d87d856c4bc9bc658c22c528bfd4" type="business"/>
  <folder name="Application" id="id-8ba93e0cda1c4d1e9b0ac95b5541830f" type="application"/>
  <folder name="Technology &amp; Physical" id="id-f1b639d8438f429c9105cf25addf0ed0" type="technology"/>
  <folder name="Motivation" id="id-5c8b65c0c4a9467dbfc30275a8f1f8c5" type="motivation"/>
  <folder name="Implementation &amp; Migration" id="id-7645db970d03422daa233d95d8aa7912" type="implementation_migration"/>
  <folder name="Other" id="id-238f0475a70442f08d2e39890c114506" type="other"/>
  <folder name="Relations" id="id-e44837d7eeac4b3587a59b0c6b42adba" type="relations"/>
  <folder name="Views" id="id-7af61afa9dba4d5aa16a3b65a2e295d0" type="diagrams">
    <element xsi:type="archimate:ArchimateDiagramModel" name="Default View" id="id-18eeb37134d743aa95f1ccb0910aae15">
      <child xsi:type="archimate:DiagramObject" id="id-339a26be3a4b413b98ac311837603ee1" archimateElement="id-2dc7c45e2dd740eb8a72c5726c13a748">
        <bounds x="455" y="323" width="120" height="55"/>
      </child>
    </element>
  </folder>
</archimate:model>

Second model:

<?xml version="1.0" encoding="UTF-8"?>
<archimate:model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:archimate="http://www.archimatetool.com/archimate" name="model_indep_2" id="id-1c8620d7bba6422daa2c194868f32e10" version="4.9.0">
  <folder name="Strategy" id="id-0701c8ef4dcc406488089b1540f80e60" type="strategy">
    <element xsi:type="archimate:Resource" name="Resource_1" id="id-2dc7c45e2dd740eb8a72c5726c13a748"/>
  </folder>
  <folder name="Business" id="id-3987d87d856c4bc9bc658c22c528bfd4" type="business">
    <element xsi:type="archimate:BusinessActor" name="Business Actor" id="id-39d0e8e8a6d9468dada3aa69067010d9"/>
  </folder>
  <folder name="Application" id="id-8ba93e0cda1c4d1e9b0ac95b5541830f" type="application"/>
  <folder name="Technology &amp; Physical" id="id-f1b639d8438f429c9105cf25addf0ed0" type="technology"/>
  <folder name="Motivation" id="id-5c8b65c0c4a9467dbfc30275a8f1f8c5" type="motivation"/>
  <folder name="Implementation &amp; Migration" id="id-7645db970d03422daa233d95d8aa7912" type="implementation_migration"/>
  <folder name="Other" id="id-238f0475a70442f08d2e39890c114506" type="other"/>
  <folder name="Relations" id="id-e44837d7eeac4b3587a59b0c6b42adba" type="relations"/>
  <folder name="Views" id="id-7af61afa9dba4d5aa16a3b65a2e295d0" type="diagrams">
    <element xsi:type="archimate:ArchimateDiagramModel" name="Default View" id="id-18eeb37134d743aa95f1ccb0910aae15">
      <child xsi:type="archimate:DiagramObject" id="id-339a26be3a4b413b98ac311837603ee1" archimateElement="id-2dc7c45e2dd740eb8a72c5726c13a748">
        <bounds x="455" y="323" width="120" height="55"/>
      </child>
    </element>
  </folder>
</archimate:model>

Diff:

[update-attribute, /archimate:model[1], name, "model_indep_2"]
[move, /archimate:model/folder[2], /archimate:model[1], 6]
[insert, /archimate:model[1], folder, 1]
[insert-attribute, /archimate:model/folder[2], id, "id-3987d87d856c4bc9bc658c22c528bfd4"]
[insert-attribute, /archimate:model/folder[2], name, "Business"]
[insert-attribute, /archimate:model/folder[2], type, "business"]
[update-attribute, /archimate:model/folder[8], id, "id-e44837d7eeac4b3587a59b0c6b42adba"]
[update-attribute, /archimate:model/folder[8], name, "Relations"]
[update-attribute, /archimate:model/folder[8], type, "relations"]
[move, /archimate:model/folder[9], /archimate:model/folder[2], 0]
[rename, /archimate:model/folder[2]/folder[1], element]
[update-attribute, /archimate:model/folder[2]/element[1], id, "id-39d0e8e8a6d9468dada3aa69067010d9"]
[update-attribute, /archimate:model/folder[2]/element[1], name, "Business Actor"]
[insert-attribute, /archimate:model/folder[2]/element[1], {http://www.w3.org/2001/XMLSchema-instance}type, "archimate:BusinessActor"]
[delete-attribute, /archimate:model/folder[2]/element[1], type]

Here you can find the schema: http://www.opengroup.org/xsd/archimate/3.0/html-view/

How can I provide the namespace prefix archimate ?

@regebro
Copy link
Contributor

regebro commented Jan 11, 2023

I can't see any Undefined namespace prefix error? You got a diff out, then there you can't have gotten that error.
The diff is unnecessarily large, though.

This issue is easiest solved by specifying that "id" is a unique attribute in your files:

xmldiff --unique-attributes=id file1.xml file2.xml

But the matching here could be improved so that this isn't necessary.

@regebro
Copy link
Contributor

regebro commented Jan 11, 2023

I just had a brainwave when it comes to the node matching, so this will be improved in 2.5, which will be released soon.

@regebro
Copy link
Contributor

regebro commented Apr 3, 2023

And 2.6 improves namespace handling.

@regebro regebro closed this as completed Apr 3, 2023
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

2 participants