Skip to content

Instantly share code, notes, and snippets.

@thewilkybarkid
Last active September 21, 2018 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thewilkybarkid/29ebd1a299d8f5eacd45959d084e285f to your computer and use it in GitHub Desktop.
Save thewilkybarkid/29ebd1a299d8f5eacd45959d084e285f to your computer and use it in GitHub Desktop.
XML element replacement
<?xml version="1.0" encoding="UTF-8"?>
<document>
<meta>
<title replaced-by="1">Some text</title>
<full-title id="1">Some text</full-title>
</meta>
<content>
<p>Some <italic replaced-by="2"><em id="2">inline</em></italic> content</p>
<image replaced-by="3">
<src>http://www.example.com/image.jpg</src>
</image>
<figure id="3">
<src>http://www.example.com/image.jpg</src>
</figure>
</content>
</document>
<?xml version="1.0" encoding="UTF-8"?>
<document>
<meta>
<title>Some text</title>
<full-title>Some text</full-title>
</meta>
<content>
<p>Some <italic><em>inline</em></italic> content</p>
<image>
<src>http://www.example.com/image.jpg</src>
</image>
<figure>
<src>http://www.example.com/image.jpg</src>
</figure>
</content>
</document>
@thewilkybarkid
Copy link
Author

These are the three types of changes I can imagine:

  1. Replacing an element in a data context.
  2. Replacing an inline element.
  3. Replacing a 'block' element.

2 and 3 look unclear without the attribute. The spec is currently saying that you have to just ignore things you don't recognise, but this is hard to do for Libero-namespaced code as we should support any Libero-namespaced things, which covers both.

@giorgiosironi
Copy link

This attributes usage seems reasonable and clear.

Being a pointer from old to new, it supports the joining case but not the splitting case, I think:

<figure replaced-by="4?">
<image>
<src>http://www.example.com/image.jpg</src>
</image>
<caption>Lorem ipsum</caption>
</figure>

<image id="4a">
<src>http://www.example.com/image.jpg</src>
</image>
<caption id="4b">Lorem ipsum</caption>

(tag names are hypothetical)

@thewilkybarkid
Copy link
Author

Can use IDREFS rather than IDREF to allow referencing multiple IDs in that case:

<figure replaced-by="4a 4b">
<image>
<src>http://www.example.com/image.jpg</src>
</image>
<caption>Lorem ipsum</caption>
</figure>

<image id="4a">
<src>http://www.example.com/image.jpg</src>
</image>
<caption id="4b">Lorem ipsum</caption>

@thewilkybarkid
Copy link
Author

Wonder about bi-directional?

<?xml version="1.0" encoding="UTF-8"?>

<document>

    <meta>
        
        <title replaced-by="1" id="i">Some text</title>
        <full-title id="1" replaces="i">Some text</full-title>
        
    </meta>

    <content>

        <p>Some <italic replaced-by="2" id="ii"><em id="2" replaces="ii">inline</em></italic> content</p>

        <image replaced-by="3" id="iii">
            <src>http://www.example.com/image.jpg</src>
        </image>

        <figure id="3" replaces="iii">
            <src>http://www.example.com/image.jpg</src>
        </figure>

        <figure replaced-by="4a 4b" id="iv">
            <image>
                <src>http://www.example.com/image.jpg</src>
            </image>
            <caption>Lorem ipsum</caption>
        </figure>

        <image id="4a" replaces="iv">
            <src>http://www.example.com/image.jpg</src>
        </image>
        <caption id="4b" replaces="iv">Lorem ipsum</caption>

    </content>

</document>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment