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

Chaining parse/write of rdf+xml leads to infinite expansion #182

Open
royludo opened this issue Apr 28, 2017 · 0 comments
Open

Chaining parse/write of rdf+xml leads to infinite expansion #182

royludo opened this issue Apr 28, 2017 · 0 comments

Comments

@royludo
Copy link

royludo commented Apr 28, 2017

The library changes the output even when nothing has changed, which leads to unfortunate consequences.
Here is the (quite simple) input:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myNS="http://www.example.org/">
  <rdf:Description rdf:about="#_000001">
    <myNS:hasProperty>
      <rdf:Bag></rdf:Bag>
    </myNS:hasProperty>
  </rdf:Description>
</rdf:RDF>

Parsing it and then writing it as application/rdf+xml (which should strictly produce the same result) produces this:

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:myNS="http://www.example.org/">
    <rdf:Description rdf:about="/#_000001">
        <myNS:hasProperty rdf:parseType="Resource">
            <rdf:Description>
                <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag"/>
            </rdf:Description>
        </myNS:hasProperty>
    </rdf:Description>
</rdf:RDF>

Doing it again on this output leads to this:

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:myNS="http://www.example.org/">
    <rdf:Description rdf:about="/#_000001">
        <myNS:hasProperty rdf:parseType="Resource">
            <rdf:Description>
                <rdf:Description rdf:parseType="Resource">
                    <rdf:Description>
                        <rdf:resource>http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag</rdf:resource>
                        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/>
                    </rdf:Description>
                </rdf:Description>
            </rdf:Description>
        </myNS:hasProperty>
    </rdf:Description>
</rdf:RDF>

And again:

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:myNS="http://www.example.org/">
    <rdf:Description rdf:about="/#_000001">
        <myNS:hasProperty rdf:parseType="Resource">
            <rdf:Description>
                <rdf:Description rdf:parseType="Resource">
                    <rdf:Description>
                        <rdf:Description rdf:parseType="Resource">
                            <rdf:Description>
                                <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#resource"/>
                                <rdf:value>http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag</rdf:value>
                            </rdf:Description>
                        </rdf:Description>
                        <rdf:Description rdf:parseType="Resource">
                            <rdf:Description>
                                <rdf:resource>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</rdf:resource>
                                <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/>
                            </rdf:Description>
                        </rdf:Description>
                        <rdf:parseType>Resource</rdf:parseType>
                    </rdf:Description>
                </rdf:Description>
            </rdf:Description>
        </myNS:hasProperty>
    </rdf:Description>
</rdf:RDF>

And so on...

<rdf:RDF
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:myNS="http://www.example.org/">
    <rdf:Description rdf:about="/#_000001">
        <myNS:hasProperty rdf:parseType="Resource">
            <rdf:Description>
                <rdf:Description rdf:parseType="Resource">
                    <rdf:Description>
                        <rdf:Description rdf:parseType="Resource">
                            <rdf:Description>
                                <rdf:Description rdf:parseType="Resource">
                                    <rdf:Description>
                                        <rdf:resource>http://www.w3.org/1999/02/22-rdf-syntax-ns#resource</rdf:resource>
                                        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/>
                                    </rdf:Description>
                                </rdf:Description>
                                <rdf:Description rdf:parseType="Resource">
                                    <rdf:Description>
                                        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#value"/>
                                        <rdf:value>http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag</rdf:value>
                                    </rdf:Description>
                                </rdf:Description>
                                <rdf:parseType>Resource</rdf:parseType>
                            </rdf:Description>
                        </rdf:Description>
                        <rdf:Description rdf:parseType="Resource">
                            <rdf:Description>
                                <rdf:Description rdf:parseType="Resource">
                                    <rdf:Description>
                                        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#resource"/>
                                        <rdf:value>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</rdf:value>
                                    </rdf:Description>
                                </rdf:Description>
                                <rdf:Description rdf:parseType="Resource">
                                    <rdf:Description>
                                        <rdf:resource>http://www.w3.org/1999/02/22-rdf-syntax-ns#type</rdf:resource>
                                        <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#type"/>
                                    </rdf:Description>
                                </rdf:Description>
                                <rdf:parseType>Resource</rdf:parseType>
                            </rdf:Description>
                        </rdf:Description>
                        <rdf:Description rdf:parseType="Resource">
                            <rdf:Description>
                                <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#parseType"/>
                                <rdf:value>Resource</rdf:value>
                            </rdf:Description>
                        </rdf:Description>
                        <rdf:parseType>Resource</rdf:parseType>
                    </rdf:Description>
                </rdf:Description>
            </rdf:Description>
        </myNS:hasProperty>
    </rdf:Description>
</rdf:RDF>

That's a lot of lines, given that no information were added.

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

1 participant