Import XML

Linking of Different Documents Within Sophora XML

How to link different documents within the Sophora XML using the attribute „externalID“.

To link different documents within the Sophora XML you can use the optional attribute externalID of the <document> element. When this external id attribute is used in a reference property somewhere else in the XML document, the Importer automatically hooks the two documents.

In the following example an image gallery containing a reference to an image object is created:

<?xml version="1.0" encoding="UTF-8"?>
<document nodeType="sophora-content-nt:imagegallery"
          xmlns="http://www.sophoracms.com/import/4.2"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <properties>
    [...]
  </properties>
  <childNodes>
    <childNode nodeType="sophora-content-nt:imageref" name="sophora-content:image">
      <properties>
        <property name="sophora:reference">
          <value>refImage01</value>
        </property>
      </properties>
      <childNodes/>
      <resourceList>
        <document nodeType="sophora-content-nt:imageobject" externalID="refImage01">
          <properties>
            [...]
          </properties>
          <childNodes>
            <childNode nodeType="sophora-extension-nt:imagedata" name="sophora-extension:imagedata">
              <properties>
                [...]
              </properties>
              <childNodes/>
              <resourceList/>
            </childNode>
          </childNodes>
          <resourceList/>
          <fields>
            [...]
          </fields>
          <instructions>
            [...]
          </instructions>
        </document>
      </resourceList>
    </childNode>
  </childNodes>
  <resourceList/>
  <fields>
    [...]
  </fields>
  <instructions>
    [...]
  </instructions>
</document>

Using this mechanism you can even import documents that reference eachother. This might be the case when two news documents reference each other as a teaser.

Last modified on 10/16/20

The content of this page is licensed under the CC BY 4.0 License. Code samples are licensed under the MIT License.

Icon