Wxml

WXML (for Wedia XML) is an XML format describing DTP documents introduced by Wedia in 2007. It is used by both Server and Desktop plug-ins.

A first WXML example

<?xml version="1.0" encoding="UTF-8"?> <WXML unit="pt" version="1.0"> <Doc version="CC 2015"> <Styles> <Style format="css" id="[No paragraph style]" name="_No_paragraph_style_" type="paragraph"><![CDATA[color:#000000; -wedia-font-variant:Regular; font-size:12pt; font-family:'Minion Pro'; margin-top:0pt; margin-bottom:0pt; margin-left:0pt; margin-right:0pt;]]></Style> <Style format="css" id="NormalParagraphStyle" name="NormalParagraphStyle" type="paragraph"><![CDATA[color:#000000; -wedia-font-variant:Regular; font-size:12pt; font-family:'Minion Pro'; margin-top:0pt; margin-bottom:0pt; margin-left:0pt; margin-right:0pt;]]></Style> <Style format="css" id="WediaParaStyle" name="WediaParaStyle" type="paragraph"><![CDATA[color:#00ffff; -wedia-font-variant:Regular; font-size:12pt; font-family:'Minion Pro'; margin-top:0pt; margin-bottom:0pt; margin-left:0pt; margin-right:0pt;]]></Style> <Style format="css" id="[No character style]" name="WEDIA_NONE" type="character" /> .... </Styles> <Layers> <Layer locked="false" name="Calque 1" visible="true" /> </Layers> <Spread height="985.889763778" left="-1190.551181102" top="-72" width="2381.102362204"> <Template> <Guides /> </Template> <Page height="841.889763778" layoutName="A4 V" left="0" top="0" width="595.275590551"> <Template> <Guides /> <Margin bottom="36" left="36" right="36" top="36" /> <Column Number="1" /> </Template> <Box class="_Normal_Text_Frame_" dynamic="false" editable="1" groupTag="" height="374.17322834645654" id="WID_254" layer="Calque 1" left="107.71653543307087" lockPosition="false" movable="-1" resizable="0" rotatable="0" rotate="0" top="198.42519685039372" width="361.4173228346457" xskew="-0"> <Text charStyles="_No_character_style_" count="0" overset="-1" paraStyles="WediaParaStyle"> <Field Img="false" charStyles="_No_character_style_" id="1" modFunc="" modName="" name="TEXTE" newParagraph="" objId="" objPath="" objType="" paraStyles="WediaParaStyle" type="html"><![CDATA[<p class="WediaParaStyle"><span class="WEDIA_NONE">Some fielded text Content</span></p>]]></Field> </Text> </Box> </Page> </Spread> </Doc> </WXML>

The WXML format is a communication medium between the Wedia engine and the rendering server. It is based on a two-way exchange using the 2 following HTTP services:

The "Get" Report service

http://[localhost|ip]:port/report?doc=path[&noSave=true|false][&noClose=true][& mode=content|template|template|structure]

  • the default listening port is 8000 for desktop plugins and 9000 for server ones. It can be set in the Wedia.cfg file

  • the document path can be an absolute one accessible on the filesystem or an relative URL to the SAN robot

  • noSave, noClose parameters are optional. They are used for debug purpose at the desktop side.

  • the reported WXML level of detail is determined by the mode parameter:

    • template: to have all the layouting information (guides, margins, columns…​) as well as the boxes but without their contents

    • content: the whole structure of the document, boxes and their contents but without template information (mode used on the server)

    • when no mode is predicted, the deferral cumulatively template and content

The request’s response contains a WXML buffer describing the DTP document as it is currently on the server. This WXML is then used as a working base (for consultation/search and/or additions/modification of data). It allows access:

  • the overall structure of the document: spreadspagesboxes/groups

  • the geometry of each element: through attributes left, top, width, height and rotate, xscale, yscale for boxes and images.

  • Text and image content whether or not mapped to database objects using Wedia Field.

  • the styles, layers and colors existing in the document

Remarks:

  • default measurement unit is the point

  • default encoding is UTF-8

  • WXML is additive: it is possible to add elements by simple insertion, modify the existing ones but it is not possible to delete elements just omitting them: you have to use a specific Processing Instruction or checkin/checkout the document itself.

The "Post" Modify service

http://[localhost|ip]:port/modify?doc=path[&noSave=true|false][&noClose=true|false]

This is the reverse operation of a Report request. It sends to the plug-in a new WXML buffer to modify the DTP document as you would like it to be after composition.

On the server side:

The communication with the rendering server is transparently handled by the DTP Manager inside the Wedia engine. It is based on the WXML, derived from the Report service, as a basis for adding and modifying data. Using web interfaces or APIs, you can use the WXML to:

  • modify attributes values, set as R/W inside WXML DTD

  • add new content under certain conditions and in compliance with the DTD:

    • add spreads inside the Doc Element

    • add pages to existing or newly created spreads

    • add boxes/groups to existing or newly created spreads/pages

    • add text fields

  • perform special commands calling some Processing Instructions

On the desktop side

In this configuration, the desktop PlugIns HTTP services are directly accessible to third party programs (e.g. Adobe CEP Palette). The modify service provides more flexibility allowing:

  • direct modification of existing Fields outside the complete XML structure. Directly add one or more Fields (whose content you want to edit) under the Doc element. E.g.:

    <WXML unit="pt" version="1.0"> <Doc> <Field Img="false" charStyles="_No_character_style_" id="1" modFunc="" modName="" name="TEXTE" newParagraph="" objId="" objPath="" objType="" paraStyles="NormalParagraphStyle" type="html"> <![CDATA[<p class="NormalParagraphStyle"><span class="WEDIA_NONE">Wedia text</span></p>]]> </Field> </Doc> </WXML>
  • Sending a partial WXML: it is possible to edit a single box or its contents inside a document containing multiple spreads, pages and multiple boxes.

WEDIA Text Fields

Plugins are able to edit texts inside the document as long as they are inserted into a specific WXML element called a Field. This WEDIA Field is the WXML pendant of the InDesign API XML node.

It owns some functional and technical attributes:

id

internaly used by Wedia plugins

type="html"

specifies the text content format: only the HTML type is currently managed

objId, objPath, objType, modName, modFunc

used to create a link to a database object: detailed description

  • paraStyles, charStyles: list of paragraph and character styles available in the UI editor here

  • newParagraph: true if consecutive Fields should be separated by a carriage return

Remarks

  • Fields linked to database objects are usually created and set up by business processes

  • Those not necessarily linked to database content can be created using WXML:

Example

<Box....> <Text charStyles="_No_character_style_" count="0" overset="-1" paraStyles="NormalParagraphStyle"> <Field Img="false" charStyles="_No_character_style_" id="2" modFunc="" modName="" name="TEXTE" newParagraph="" objId="" objPath="" objType="" paraStyles="NormalParagraphStyle" type="html"><![CDATA[<p class="NormalParagraphStyle"><span class="WEDIA_NONE">editable text</span></p>]]></Field> </Text> </Box>

WXML Processing Instructions

Processing instructions, named PINSTR, are special directives to be included in the WXML during a Modify operation. They are sent on demand to delegate specific orders to the PlugIns and are never returned by the Report service.

Box deletion

As mentioned above, WXML is an "additive" format. We can easily add or modify existing content, but you must call a PInstr delete to remove content:

Syntax

It has to be inserted as a child of the Box element to allow deletion of the parent.

Example

Text box automatic tagging

New text Field creation can be achieved by adding the Field element into the WXML. That said, it is preferable to delegate it to the PlugIns to get rid of constraints such as:

  • id attribute handling (which as to be unique for a given document)

  • pre-filling of the paraStyles and charStyles attributes with those currently used in the text box if any

It has to be inserted as a child of the Text element to create a new Wedia Field.

Example

Document import

Syntax

What PInstr is currently doing:

  1. it opens the document pointed by the URL in an invisible and unlocked mode

  2. copies all the boxes contained in the 1st spread and in all the pages of the 1st spread

  3. and paste them into the destination document at the place specified by the WXML

Various remarks

  • if styles, colors or layers do not exist in the destination document, they are automatically imported. If there are name collisions, the destination document elements will prevail.

  • it is possible to update on the fly imported boxes, as shown in the following example (WIDs are those of the source document! they are recomputed after import to avoid collisions with the ones of the destination document)

  • you can group imported boxes by encapsulating the PInstr inside a Group element as in the following example

Example

 

Extended WXML functionalities for document transformation into RTL languages and/or exotic fonts

LTR => RTL transformation

Syntax

It transforms the entire layout of the document to read from right to left, applying horizontal symmetry. It systematically activates the Adobe world ready composer and applies the RTL reading direction text attribute.

Various options:

  • lang: this option is used to apply a language parameter to all document styles using the associated hyphenation library.

  • flipImages: allows images in the document to be inverted, on request, by applying horizontal symmetry.

  • convertAllFields: In addition to layout transformation, this option can be used to transform the text content of each Wedia Field inside the document. RTL specific text attributes are applied: horizontal alignment to the right, RTL text direction…

Example

Fonts replacement

Syntax

This instruction is used to substitute fonts from a source document (often a Latin-language master) to a destination document translated into a non-Latin language using so-called exotic fonts. It scans the document's styles and text content, replacing each font_to_replace in the list with the corresponding replacement_font.

The 2 parameters are mandatory and designate fonts by their postscript name.

Example

Translation service (DeepL)

Syntax :

This instruction calls the translation service implemented as a Wedia Server Plugin (currently limited to DeepL). It is inserted into the WXML when a modify is called, and will translate all the fields present in the InDesign support.

The toparameter is mandatory and indicates the language in which the translation is to be performed. The fromparameter is mandatory if the lang attribute is not present inside the Doc element of the WXML (as in the following example). These 2 parameters are ISO 639-1 codes (e.g. fr, en...).

Example :

Note :

The Wedia.cfg file on the composition server and the DeepL API plugin must be configured together for the service to work properly.

The specific case of translations

The 3 previous PInstr, which are used in translation processes, can now be chained in a single modify call like this :

This enables significant optimization in the specific cases of Arabic/Hebrew or other exotic languages where several separate calls may have been necessary.

There is no specific order for the calls, as the indesign plugin manages its own private technical priorities, but I recommend calling them in the order shown in the previous example.

Note: this PInstr chaining is only available in version 2024.1.4 and higher.