mans
mans

Reputation: 18178

are these two xml equivalent?

I have these two xml documents:

<rdf:Description rdf:about=""
    xmlns:GPano="http://ns.google.com/photos/1.0/panorama/"
  GPano:ProjectionType="equirectangular"
  GPano:UsePanoramaViewer="True"
  GPano:CroppedAreaImageWidthPixels="8000"
  GPano:CroppedAreaImageHeightPixels="4000"
  GPano:FullPanoWidthPixels="8000"
  GPano:FullPanoHeightPixels="4000"
  GPano:CroppedAreaLeftPixels="0"
  GPano:CroppedAreaTopPixels="0"
  GPano:PoseHeadingDegrees="0.0"/>

and

<rdf:Description rdf:about = "" xmlns:GPano="http://ns.google.com/photos/1.0/panorama/">
  <GPano:UsePanoramaViewer>True</GPano:UsePanoramaViewer>
  <GPano:ProjectionType>equirectangular</GPano:ProjectionType>
  <GPano:PoseHeadingDegrees>0.0</GPano:PoseHeadingDegrees>
  <GPano:CroppedAreaImageWidthPixels>8000</GPano:CroppedAreaImageWidthPixels>
  <GPano:CroppedAreaImageHeightPixels>4000</GPano:CroppedAreaImageHeightPixels>
  <GPano:FullPanoWidthPixels>8000</GPano:FullPanoWidthPixels>
  <GPano:FullPanoHeightPixels>4000\</GPano:FullPanoHeightPixels>
  <GPano:CroppedAreaLeftPixels>0</GPano:CroppedAreaLeftPixels>
  <GPano:CroppedAreaTopPixels>0</GPano:CroppedAreaTopPixels>
</rdf:Description>​

Are they the same? I can see there are some syntax differences, but I am not sure if they are the same?

The reason for my question is that standard (https://developers.google.com/streetview/spherical-metadata) specifies that the second version is correct, but when I add xmp using this site:http://photo-sphere.appspot.com/ it adds xmp as shown in the first example.

Upvotes: 1

Views: 128

Answers (2)

Jon Hanna
Jon Hanna

Reputation: 113322

As XML, they are not the same, because attributes and elements are completely different.

As RDF/XML they are completely the same, because the way RDF/XML uses attributes and elements gives those in these examples the same meaning.

Much like while having &#x41;&#x42;&#x43; and ABC would be completely different text, but equivalent XML, so these examples have completely different XML but equivalent RDF.

RDF is composed of statements describing relationships between resources (identified with a URI), and either other resources or literal values (URI or string) and predicates that are also identified with a URI.

RDF/XML uses namespaces and local names to give compact forms of the URIs.

So considering that the relative URI "" means "this resource itself", the first statement we get from the first document is:

<> <http://ns.google.com/photos/1.0/panorama/ProjectionType> "equirectangular" .

(Where <> is being used for the URI of the containing resource itself, you could expand it to a full URI for that resource if you had it).

In the second document, the ProjectionType element gives the statement:

<> <http://ns.google.com/photos/1.0/panorama/ProjectionType> "equirectangular" .

And so on. They are the same RDF either way.

Some uses of RDF/XML restrict which approach can be used where, but XMP does not.

So, while the direct answer to your question "are these two xml equivalent?" is "no", the more pertinent question, "are these two XML equivalent, in terms of how they are used?" is "yes".

If you can choose between them I'd favour the former, as unless you need multiple statements with the same predicate (can't be done with attributes, as you can have only one of each name) or complex objects of the statement (requires further XML nodes), then attributes are the more concise form.

Upvotes: 1

Dabbler
Dabbler

Reputation: 9873

Absolutely not the same. In the first example, the root node's child nodes are attributes, and in the second example, the root node's child nodes are elements. The difference will become apparent e.g. when validating against a schema, or applying XPath or XSLT. So technically, there is a big difference.

However, the intent of your question may be whether there is a semantic difference for the application that consumes such XML. That is up to the application, and there is no immediate reason why one structure would be "correct" and the other would be "wrong". Of course, future extensibility and personal taste play a role in how the XML is modeled.

(After your edit:)

Photosphere generates a JPG image, no? So the panorama information will be stored as binary data in the JPG file. I guess you extracted that binary data from the JPG file to XML using some other tool, so provided you must have elements, that tool needs to be configured to create XML elements, not attributes. However, other answers indicate that the difference does not matter to RDF.

Upvotes: 0

Related Questions