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

Prefix breaks in version 0.3.20 #152

Closed
Novtopro opened this issue Nov 6, 2024 · 6 comments · Fixed by #168
Closed

Prefix breaks in version 0.3.20 #152

Novtopro opened this issue Nov 6, 2024 · 6 comments · Fixed by #168
Assignees
Labels
bug Something isn't working

Comments

@Novtopro
Copy link
Contributor

Novtopro commented Nov 6, 2024

In version 0.3.19, the spec below works as expected

CleanShot 2024-11-06 at 09 29 31@2x

but in 0.3.20 and above, it does not

CleanShot 2024-11-06 at 09 32 04@2x

The prefix is gone.

FYI @ronaldtse @HassanAkbar

Can be reproduced in metanorma/niso-jats#19 by updating the gem version.

@ronaldtse ronaldtse added the bug Something isn't working label Nov 6, 2024
@ronaldtse
Copy link
Contributor

Thank you @Novtopro for the report. This was exactly why I was worried about the fix for #150 because inner elements were not tested.

@HassanAkbar @suleman-uzair can we fix this ASAP with additional specs as mentioned in #151 ?

@HassanAkbar
Copy link
Member

@ronaldtse Sure, I'm on it.

@ronaldtse
Copy link
Contributor

@HassanAkbar ok I am a bit confused with namespace behavior.

This is the XML Namespaces specification.

The "fully namespaced name" of an element name or an attribute, which contains a "namespace name" and a "local name" is called the "expanded name".

Look at 6.2, the "larger example":

<?xml version="1.0"?>
<!-- initially, the default namespace is "books" -->
<book xmlns='urn:loc.gov:books'
      xmlns:isbn='urn:ISBN:0-395-36341-6'>
    <title>Cheaper by the Dozen</title>
    <isbn:number>1568491379</isbn:number>
    <notes>
      <!-- make HTML the default namespace for some commentary -->
      <p xmlns='http://www.w3.org/1999/xhtml'>
          This is a <i>funny</i> book!
      </p>
    </notes>
</book>

If a "default namespace" is defined at a parent element, all unprefixed child elements are supposed to be of the same namespace.

  • "title" is actually "urn:loc.gov:books:title".
  • "notes" is "urn:loc.gov:books:notes".

If a "default namespace" is defined on an element inside a tree that has a "default namespace" already defined, only the closest "default namespace" is used.

In the next example:

<?xml version='1.0'?>
<Beers>
  <!-- the default namespace inside tables is that of HTML -->
  <table xmlns='http://www.w3.org/1999/xhtml'>
   <th><td>Name</td><td>Origin</td><td>Description</td></th>
   <tr> 
     <!-- no default namespace inside table cells -->
     <td><brandName xmlns="">Huntsman</brandName></td>
     <td><origin xmlns="">Bath, UK</origin></td>
     <td>
       <details xmlns=""><class>Bitter</class><hop>Fuggles</hop>
         <pro>Wonderful hop, light alcohol, good summer beer</pro>
         <con>Fragile; excessive variance pub to pub</con>
         </details>
        </td>
      </tr>
    </table>
  </Beers>

When a namespace is set to the empty string "", then the applicable default namespace is cleared (no namespace).

  • "brandName", "origin", "details" have no namespace.

According to 6.3, "default namespace does not apply to attribute names":

<!-- http://www.w3.org is bound to n1 and is the default -->
<x xmlns:n1="http://www.w3.org" 
   xmlns="http://www.w3.org" >
  <good a="1"     b="2" />
  <good a="1"     n1:a="2" />
</x>

Therefore

We should obviously use these examples as specs.

@ronaldtse
Copy link
Contributor

@Novtopro I believe this problem has been resolved in 0.3.24. Could you help check? Thanks!

@Novtopro
Copy link
Contributor Author

The issue is still there
CleanShot 2024-11-15 at 09 43 03@2x

CleanShot 2024-11-15 at 09 44 02@2x

FYI @ronaldtse @HassanAkbar

@ronaldtse ronaldtse reopened this Nov 15, 2024
@ronaldtse
Copy link
Contributor

Thanks @Novtopro !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants