Working with XML stories. Adobe InCopy CS6

Add to My manuals
105 Pages

advertisement

Working with XML stories. Adobe InCopy CS6 | Manualzz

XML Adding XML elements to a story 99 var myDocument = app.documents.add(); var myRootXMLElement = myDocument.xmlElements.item(0); var myXMLTag = myDocument.xmlTags.add("myXMLElement"); var myXMLElement = myRootXMLElement.xmlElements.add(myXMLTag); myXMLElement.contents = "This is content in an XML element."; myXMLElement.convertToAttribute();

//Place the XML content so that you can see the result of the change.

var myStory = myDocument.stories.item(0); myStory.placeXML(myRootXMLElement);

You also can convert an XML attribute to an XML element, as shown in the following script fragment (from the ConvertAttributeToElement tutorial script): var myRootXMLElement = myDocument.xmlElements.item(0); var myXMLElementB = myRootXMLElement.xmlElements.item(1);

//The "at" parameter can be either LocationOptions.atEnd or

LocationOptions.atBeginning, but cannot

//be LocationOptions.after or LocationOptions.before.

myXMLElementB.xmlAttributes.item(0).convertToElement(XMLElementLocation.elementEnd, myDocument.xmlTags.item("myXMLElement"));

Working with XML stories

When you import XML elements that were not associated with a layout element (a story or page item), they are stored in an XML story. You can work with text in unplaced XML elements just as you would work with the text in a text frame. The following script fragment shows how this works (for the complete script, see XMLStory): var myXMLStory = myDocument.xmlStories.item(0);

//Though the text has not yet been placed in the layout, all text

//properties are available.

myXMLStory.texts.item(0).pointSize = 72;

//Place the XML element in the layout to see the result.

myDocument.xmlElements.item(0).xmlElements.item(0).placeXML(myDocument.pages.item(0).

textFrames.item(0));

Exporting XML

To export XML from an InCopy document, export either the entire XML structure in the document or one

XML element (including any child XML elements it contains). The following script fragment shows how to do this (for the complete script, see ExportXML): myDocument.exportFile("XML", File("/c/test.xml")

Adding XML elements to a story

Previously, we covered the process of getting XML data into InCopy documents and working with the XML structure in a document. In this section, we discuss techniques for getting XML information into a story and applying formatting to it.

advertisement

Related manuals

Download PDF

advertisement

Table of contents