Structure documents for XML

The Structure pane displays, in hierarchical form, items in a document that have been marked with XML tags. These items are called elements. You can move elements in the Structure pane to define the order and hierarchy of items. An element consists of an icon indicating the element type and a tag name.

Structure pane
Structure pane

A. Triangle to expand or collapse elements B. Element C. Text snippet D. Attribute 

Additionally, elements may provide this information:

Blue diamond

A blue diamond on an element icon means that the element is attached to an item on the page; the absence of a blue diamond means that the element has not been attached to a page item.

Underline

The tag name is underlined if the item on the page to which the element corresponds is selected. For example, if you select text to which you assigned the Title tag, the word Title in the text’s element is underlined in the Structure pane. Underlining shows you whether selected items on the page and elements in the Structure pane correspond.

Text snippet

The first 32 characters of tagged text, called a text snippet, can appear to the right of the element. These snippets help you identify the page item to which an element corresponds.

Dot and attribute

Attributes provide metadata information about an element. If attributes are attached to an element, a black dot along with attribute names and values appear below the element.

Use the Structure pane

  • To open the Structure pane, select View > Structure > Show Structure.
  • To close the Structure pane, select View > Structure > Hide Structure or select the splitter button.
  • Select the triangle next to the element to expand or collapse an element (and display or hide any child elements).
  • To adjust the size of the Structure pane, drag the splitter button.
  • Hold down Ctrl (Windows) or Command (macOS) while clicking the triangle next to the element to expand or contract an element and all elements within it.
  • Select Show Text Snippets or Hide Text Snippets from the Structure pane menu to show or hide text snippets.

Structure pane icons

The following icons appear in the Structure pane:

Icon

Name

Use

 

Root element

Each document includes one root element at the top, which can be renamed but cannot be moved or deleted.

 

Story element

Represents tagged stories (one or more linked frames).

 

Text element

Represents tagged text within a frame.

 

Graphic element

Represents a tagged frame that includes a placed image. Each graphic element includes an href attribute that defines the path or URL to the linked file.

 

Unplaced text element

Unplaced text element not yet associated with a page item.

 

Unplaced graphic element

Unplaced graphic element not yet associated with a page item.

 

Table element

Represents a table.

 

Header cell element

Represents a cell in the header row of a table.

 

Body cell element

Represents a cell within the body of a table.

 

Footer cell element

Represents a cell in the footer row of a table.

 

Empty element

An empty frame is associated with this element.

 

Attribute

Includes metadata, such as keywords or location of a linked image (HREF attribute).

 

Comment

Includes comments that appear in the XML file, but not the InDesign document.

 

Processing instruction

Includes an instruction that triggers an action in applications that can read processing instructions.

 

DOCTYPE element

Tells InDesign which DTD file to use when validating the XML file.

Rearrange structured elements

You can change the order and hierarchical rank of elements in the Structure pane. However, observe these rules:

  • An XML document is required to have a single root element at the top of the structure. The root element contains and is the parent to all other elements. Only the DTD (appearing as a DOCTYPE element), comments, and processing instructions may appear above the root element in the Structure pane.

  • Changes to the XML hierarchy structure may affect the appearance of tagged items on InDesign pages. For example, making a text element the child of an element elsewhere in the structure also moves the text in the layout.

  • You cannot drag a table cell element into a table element or move elements into a table element.

  1. In the Structure pane, do one of the following:
    • To move an element, drag it to a new location within the structure. A line appears when you drag to indicate where you are inserting the element. The width of the line marks the level within the hierarchy.

    • To make an element a child of another element, either position it over the parent element to highlight it or place it amongst the parent’s other child elements, and then release the mouse button.

    • To demote an element by one level in the hierarchy, drag it just above another parent element and move it to the left slightly until the line indicating its placement spans the width of the parent element.

    • To copy or cut an element, select the element or elements in the Structure pane, and then choose Edit > Copy or Edit > Cut. Select the element directly above where you want to insert the element, and choose Edit > Paste.

Note:

When you cut an element, the element and contents are cut to the clipboard, but the frame remains intact.

Insert a parent element

Insert a parent element in the Structure pane to maintain the proper XML structure or organize content better. Before you can insert a new parent element, you must select the elements that will be the children of the new parent. When the new parent element is inserted, the selected child elements are demoted by one rank in the structural hierarchy.

With child elements selected (left); a newly inserted parent element includes the child elements (right).
With child elements selected (left); a newly inserted parent element includes the child elements (right).

With child elements selected (left); a newly inserted parent element includes the child elements (right).
With child elements selected (left); a newly inserted parent element includes the child elements (right).

  1. In the Structure pane, select the elements that will be child elements to the new parent element you want to insert. Note the following:

    • You can’t select the Root or a root-level element.

    • You can’t select the Story or a story-level element.

    • The elements must be on the same level of the structural hierarchy.

    • The elements must be contiguous.

    • The selection must not include table cells or attributes.

  2. On the Structure pane menu, select New Parent Element, right-click (Windows) or Control-click (macOS) and select New Parent Element.

  3. Select a tag for the new parent element and select OK.

Note:

Insert a new parent element quickly by selecting Add Tag in the Tags panel and then selecting a tag in the panel. You can also right-click (Windows) or Control-click (macOS) an element you selected in the Structure pane, select New Parent Element, and then select an element.

Work with attributes

An attribute provides additional information about an XML element. Each attribute consists of a name and a value. Attributes appear in the Structure pane; they are not placed in the document or used as content in the document. Include attributes with elements for the benefit of files and applications that will use the XML files you create in InDesign.

When you tag an image, InDesign automatically creates an href attribute with a value that defines the on-disk location of the image file. This href attribute allows other files and applications to locate the image on disk so it can be displayed.

An attribute includes a name (href, in this case) and a value.
An attribute includes a name (href, in this case) and a value.

You can add attributes to any element except the DOCTYPE element (a DTD file), comments, and processing instructions. For example, to include keywords for searching in a downstream application, you can create an attribute called keywords. You could also create attributes to indicate substituted text, track article titles, and record other content-related information.

Note:

If you are using a DTD file, view its contents to see which attributes it allows. Attribute names, like tag names, must conform to the DTD.

Note:

InDesign recognizes special namespace attributes that can specify paragraph or character styles, tables, and table cell styles, as well as control whitespace. For more information, view the InDesign guide.

Add an attribute

  1. Select an element.
  2. Do one of the following:
    • Select the Add An Attribute  button.

    • Select New Attribute on the Structure pane menu.

    • Right-click (Windows) or Control-click (macOS) the selected element and select New Attribute.

  3. Specify a name and a value for the attribute, and then click OK.

Show or hide attributes in the Structure pane

  1. Choose Show Attributes or Hide Attributes from the Structure pane menu.

    You may need to click the triangle icon next to an element to display its attributes.

Edit or delete an attribute

  1. Select an attribute in the Structure pane.
  2. Do one of the following:
    • To edit the attribute, double-click it or choose Edit from the Structure pane menu.

    • To delete the attribute, click the Delete icon or choose Delete from the Structure pane menu.

Edit href attributes

InDesign creates href attributes automatically to handle image files. The href attribute defines the on-disk location of the image file so that the image file can be displayed. When you tag a placed image, InDesign creates an href attribute value that lists the image’s path and filename.

The path can be an absolute link, a relative link to the same folder as the XML file, or a relative link to the Images subfolder of the folder where the XML file is located. Relative paths are specific to the path where the document is saved.

  • An href attribute with an absolute link looks like the following (in Windows and the Mac OS):

    href=file:///C:/Images/Meadow.psd

    href=file:///Users/abhayc//Desktop/abc.jpg

  • An href attribute to an image file in the same folder as the XML file looks like the following:

    href=file:Meadow.psd

  • An href attribute to an image file in the Images subfolder looks like the following:

    href=file:///Images/Meadow.psd

You can edit the href attribute to specify a new link to an image. For example, you can edit an absolute link to make it a relative link, thereby making the image file accessible when you export the file.

  1. In the Structure pane, double-click the href attribute. (You may need to click the triangle icon next to the image element to display the attribute.)
  2. For Value, enter the new path to the image, and then click OK.

Add comments and processing instructions

Using InDesign, you can include comments and processing instructions in an XML file. Enter a comment to include descriptive information about an element. Comments can be viewed in web browsers and text editors. They help others understand XML structure and XML tags. A processing instruction is a special, application-specific command. For example, you can enter a page-break processing instruction so that an application to which you export your XML file understands where to enter a page break. InDesign user-created processing instructions are meant for use in other programs; InDesign itself does not act on processing instructions.

InDesign Structure pane with text snippets showing
InDesign Structure pane with text snippets showing

A. Processing instruction B. Comment 

Comments and processing instructions appear in the Structure pane. You can move, edit, and delete comments and processing instructions as you can other elements in the Structure pane. They cannot, however, contain child elements or attributes.

Add a comment

  1. Select the element about which you will comment.
    Note:

    To add a comment to a table, select a table cell element. You can add comments to table cells, not tables.

  2. Choose New Comment in the Structure pane menu.
  3. Type the comment in the New Comment dialog box.

Add a processing instruction

  1. Select an element for the processing instruction.
    Note:

    To add a processing instruction to a table, select a table cell element. You can add processing instructions to table cells, not tables.

  2. Choose New Processing Instruction in the Structure pane menu.
  3. For Target, enter a name that identifies the processing instruction to an application that reads exported XML files.
  4. For Data, enter a value that tells the application what to do with the processing instruction.

View comments and processing instructions

  1. Choose Show Comments or Show Processing Instructions in the Structure pane menu.

Edit comments and processing instructions

  1. Select the comment or processing instruction.
  2. Do any of the following:
    • Double-click the comment or processing instruction.

    • Choose Edit on the Structure pane menu.

  3. Edit the comment or processing instruction and click OK.

Use DTD files to validate XML

Validating the XML in a document means to compare the structure, element tag names, and attributes against the specifications of a DTD file. To validate against a DTD file, you must first load it into your document in InDesign.

The DOCTYPE element appears at the top of the Structure pane if a DTD file has been loaded into your document. (DTDs are sometimes loaded automatically when you import an XML file.) To replace the DTD file in a document, delete the existing DTD and then load a new one.

Working with DTD files in InDesign

A. DOCTYPE element from the DTD file (Structure pane) B. Locked tag from the DTD file (Tags panel) 

Note:

Loading a DTD file imports tag names into the Tags panel. These imported tag names are locked; they can’t be deleted or renamed except by deleting the DTD file from the document.

Load a DTD file

When you load a DTD file, InDesign embeds the file in the document.

  1. Do one of the following:
    • In the Structure pane, choose Load DTD from the Structure pane menu.

    • In the Tags panel, choose Load DTD from the panel menu.

  2. Select a DTD file to import, and click Open.
    Note:

    To view tags defined in the DTD file, open the Tags panel by choosing Window > Utilities > Tags.

View a DTD file

DTDs are written in ASCII text. They may contain embedded instructions and explanations that describe how to apply tags and order elements correctly. In InDesign, you can only view a DTD that is loaded in a document.

  1. Do one of the following:
    • In the Structure pane menu, choose View DTD.

    • Double-click the DOCTYPE element in the Structure pane.

DTD file opened for viewing
DTD file opened for viewing

Note:

To print a DTD file, copy code from the View DTD window and paste it in a text editor.

Delete a DTD file

  1. Choose Delete DTD from the Structure pane menu.

    InDesign deletes the copy of the DTD file stored in the InDesign document, not the original DTD file. Tags that were imported with the DTD file remain in the Tags panel but are unlocked.

Validate XML structure

When you validate your document, InDesign alerts you if the XML deviates from rules established by the DTD file. It suggests ways to make the XML meet DTD file requirements. You can fix errors one at a time or view all errors in a separate window.

Structure pane with Suggestions pane
Structure pane with Suggestions pane

A. Loaded DTD B. Error or invalidating condition C. Description of error with suggested fix D. Error count E. Validate button F. View all errors in a separate window 

Structure pane with Suggestions section
Structure pane with Suggestions section

A. DOCTYPE element from assigned DTD file B. Error or invalidating condition C. Description of error with suggested fixes D. Error count E. Validate button F. View all errors at once in a separate window 

  1. Choose View > Structure > Show Structure.
  2. In the Structure pane, click the Validate button  .
    Note:

    To change the root element from which InDesign validates, choose DTD Options in the Structure pane menu.

  3. To fix errors displayed in the Suggestion pane, either click a suggested fix to try it, or edit the XML structure and tags directly using the Structure pane and the Tags panel.
  4. To view other errors, do one of the following:
    • Click the Left arrow  or Right arrow .

    • Click the Error Window button  to view all errors in a separate window.

    • Choose View List Of Errors on the Structure pane menu.

Note:

InDesign stops validating after detecting 250 errors. A plus sign in the Error Count box appears when this limit is reached.

related resources

Talk to us

We would love to hear from you. Share your thoughts with the Adobe InDesign Community

 Adobe

Get help faster and easier

New user?