PTC ALD in Arbortext Styler > Components of Documents and Templates > Content Types > XML Content Streams
  
XML Content Streams
Introduction
There are two types of XML content stream in PTC Arbortext Layout Developer:
XML text streams — an editable text stream, much like the standard text streams discussed in Basic Text Streams
XML DOM streams — an XML DOM stream
Both XML text streams and XML DOM streams can be used as frame content and formatted.
Refer to XML in PTC Arbortext Layout Developer for information about PTC Arbortext Layout Developer’s XML capabilities.
XML Text Streams
The PTC Arbortext Layout Developer tag type .xm represents XML text streams. XML content can also be held by other types of tag, for example .tx and .rf, but for purposes of clarity it is useful to always use .xm tags.
The key difference between .xm tags and text stream tags (.tx) is that PTC Arbortext Layout Developer always tries to parse the content of an .xm tag as XML and create a DOM tree from it. If that is not possible, PTC Arbortext Layout Developer creates an error tag of type .xe in the xerror namespace. The error tag has the same name as the XML tag containing the error. It contains a description of the error that PTC Arbortext Layout Developer’s XML parser encountered in the content.
The XML DOM created from these tags is read only. You can perform XPath expressions and run XSLT against the DOM but PTC Arbortext Layout Developer’s DOM functionality cannot modify it.
XML streams have a number of properties that can make PTC Arbortext Layout Developer more flexible in its handling of XML text content.
* 
Many of the properties of XML streams are irrelevant for XML DOM streams. They instruct PTC Arbortext Layout Developer how to parse the XML content to create the DOM tree.
These properties are part of the fStream object — there is no differentiation between PTC Arbortext Layout Developer’s text streams and XML content streams:
fStream.isXML — specifies whether PTC Arbortext Layout Developer should consider the content as XML. This is set to on by default only in .xm streams, but can be activated for other content stream types.
fStream.xmlParseError — contains the last parsing error generated if PTC Arbortext Layout Developer cannot build a tree from the XML in a stream for which the isXML property is true. The error can then be used to test whether a tree has been built from content.
fStream.xmlErrorPosLast and fStream.xmlErrorPosCurrent — provide information about the place in content where errors occurred during parsing
fStream.xmlValidate — instructs PTC Arbortext Layout Developer that XML content should be validated against a DTD. By default,PTC Arbortext Layout Developer does not attempt to validate XML content.
fStream.xmlValidError — reports the last of any validation errors generated when PTC Arbortext Layout Developer tries to validate XML content
fStream.xmlCatalog — specifies the location of the XML catalog to use when validating the XML instance
fStream.xmlBaseURI — sets a base URI for the stream, from which to resolve paths relative to the content source.
Problems can occur in XML instances that contain relative links to external content if the location of the current document or template is not the same as the location of the source of the XML instance.
fStream.xmlLoadExternal — instructs PTC Arbortext Layout Developer to load content that is referenced in the XML content, for example entities. If the property is set to true, PTC Arbortext Layout Developer creates document tags for that content. Otherwise it accesses the external file directly.
XML text streams provide a read-only XML DOM that can be accessed through PTC Arbortext Layout Developer’s DOM implementation.
XML DOM Streams
.xd type tags represent XML DOM streams. They are tags to which a read-write XML DOM can be attached. You cannot edit the DOM tag directly in PTC Arbortext Layout Developer. If you click into an XML DOM stream a temporary placeholder tag, with the tag type !!!, is generated for edit.
* 
It is not recommended that you make edits to the !!! DOM placeholder tag unless you have extensive experience. If the content is not well formed after edits to the stream, and PTC Arbortext Layout Developer attempts to recreate the DOM during a reformat action, all the DOM content will be lost, and cannot be retrieved.
As the XML DOM associated with the XML DOM stream is read-write, you can use W3C DOM Level 2 Core JavaScript functionality to manipulate the DOM. Refer to DOM Access from JavaScript for information.
Best Practices
Do not edit XML DOM stream content unless you are wholly confident. The potential to lose all the DOM content is very high.