Exporting editions structure
Here is an example XSLT that export the structure of one or more editions - i.e. the list of pages, master pages, layers and external documents contained in the edition.
<eop:XmlExportOptions xmlns:eop="http://www.teradp.com/schemas/GN4/1/XmlExportOptions.xsd" DataMaxSize="0" AccessStrict="false" MimeType="application/xml" NavOptions="Referencing" XsltUrl="self://localhost/do.ashx?cmd=config&name=xsl_EditionStructure"> </eop:XmlExportOptions> |
<?xml version="1.0" encoding="utf-8"?> <!-- EditionContent
Outputs a XML file describing the structure of one or more editions --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:lc="http://www.teradp.com/schemas/GN4/1/LoginContext.xsd" xmlns:oc="http://www.teradp.com/schemas/GN4/1/OperationContext.xsd" xmlns:fn="http://www.teradp.com/schemas/GN4/1/Xslt" xmlns:nav="http://www.teradp.com/schemas/GN4/1/ObjNav.xsd" xmlns:gn4="urn:schemas-teradp-com:gn4tera" xmlns:extra="urn:schemas-teradp-com:gn4ObjectExtra" exclude-result-prefixes="msxsl lc oc fn nav extra gn4">
<!-- Common parameters -->
<xsl:param name="context"/> <xsl:param name="pars"/>
<xsl:variable name="whUnit"> <xsl:choose> <xsl:when test="$pars and $pars/*/add[@key='unit']"> <xsl:value-of select="$pars/*/add[@key='unit']/@value"/> </xsl:when> <xsl:otherwise> <xsl:text>m</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable>
<xsl:template match="gn4:master"> <master id="{fn:objectIdFromString(@id)}" name="{@name}" masterType="{@masterType}" twoSides="{@twoSides}" width="{fn:convertUnit(@width,'length','m',$whUnit)}" height="{fn:convertUnit(@height,'length','m',$whUnit)}"/> </xsl:template>
<xsl:template name="workstate"> <xsl:if test="gn4:workstateRef/@idref"> <xsl:attribute name="workstateId"> <xsl:value-of select="fn:objectIdFromString(gn4:workstateRef/@idref)"/> </xsl:attribute> <xsl:attribute name="workstateName"> <xsl:value-of select="gn4:workstateRef/nav:refObject/*/@name"/> </xsl:attribute> </xsl:if> </xsl:template>
<xsl:template name="sectionZoneWorkstate"> <xsl:attribute name="sectionId"> <xsl:value-of select="fn:objectIdFromString(gn4:sectionRef/@idref)"/> </xsl:attribute> <xsl:attribute name="sectionName"> <xsl:value-of select="gn4:sectionRef/nav:refObject/*/@name"/> </xsl:attribute> <xsl:attribute name="zoneId"> <xsl:value-of select="fn:objectIdFromString(gn4:zoneRef/@idref)"/> </xsl:attribute> <xsl:attribute name="zoneName"> <xsl:value-of select="gn4:zoneRef/nav:refObject/*/@name"/> </xsl:attribute> <xsl:call-template name="workstate"/> </xsl:template>
<xsl:template name="layer"> <xsl:param name="layer"/> <layer id="{fn:objectIdFromString($layer/@id)}" name="{$layer/@name}" layerTypeId="{fn:objectIdFromString($layer/gn4:layerTypeRef/@idref)}" layerTypeName="{$layer/gn4:layerTypeRef/nav:refObject/*/@name}"> </layer> </xsl:template>
<xsl:template match="gn4:page"> <page id="{fn:objectIdFromString(@id)}" logicalPage="{@logicalPage}" double="{gn4:masterRef/nav:refObject/*/@twoSides}" leftColor="{@leftColor}" rightColor="{@rightColor}" autoDeadline="{@autoDeadline}" number="{@number}"> <xsl:call-template name="sectionZoneWorkstate"/> <layers> <xsl:for-each select="gn4:layers/gn4:ref"> <layer idref="{fn:objectIdFromString(@idref)}"/> </xsl:for-each> </layers> </page> </xsl:template>
<xsl:template match="gn4:extDoc"> <extDoc id="{fn:objectIdFromString(@id)}" autoDeadline="{@autoDeadline}" name="{@name}"> <xsl:call-template name="sectionZoneWorkstate"/> </extDoc> </xsl:template>
<xsl:template match="gn4:edition"> <xsl:variable name="masters" select="nav:referencing/nav:referencingBy[@attrName='master.editionRef']/nav:refs/nav:refObject/gn4:master"/> <xsl:variable name="extDocs" select="nav:referencing/nav:referencingBy[@attrName='extDoc.editionRef']/nav:refs/nav:refObject/gn4:extDoc"/> <xsl:variable name="pages" select="nav:referencing/nav:referencingBy[@attrName='page.editionRef']/nav:refs/nav:refObject/gn4:page"/> <xsl:variable name="pageLayers" select="$pages/gn4:layers/gn4:ref/nav:refObject/*"/> <edition id="{fn:objectIdFromString(@id)}"> <xsl:call-template name="workstate"/> <masters> <xsl:apply-templates select="$masters"/> </masters> <pages> <xsl:apply-templates select="$pages"/> </pages> <extDocs> <xsl:apply-templates select="$extDocs"/> </extDocs> <layers> <xsl:for-each select="fn:distinct($pageLayers/@id,'Ordinal')/*"> <xsl:variable name="id" select="."/> <xsl:variable name="sameKeyPageLayers" select="$pageLayers[@id=$id]"/> <xsl:variable name="firstPageLayer" select="$sameKeyPageLayers[1]"/> <xsl:call-template name="layer"> <xsl:with-param name="layer" select="$firstPageLayer"/> </xsl:call-template> </xsl:for-each> </layers> </edition> </xsl:template>
<xsl:template match="gn4:objects"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="/"> <objects> <xsl:apply-templates/> </objects> </xsl:template>
</xsl:stylesheet>
|
Import both configuration files in the database, and then you can get the XML of an edition calling:
../do.ashx?cmd=feed&name=EditionStructure&ids=XXX
where XXX is the id of the edition (or multiple editions separated by comma).
The output XML is something like this:
<objects>
<edition id="2767">
<masters>
<master id="2768" name="Left" masterType="Left" twoSides="false"
width="822197" height="1180667" />
<master id="2769" name="Right" masterType="Right" twoSides="false"
width="822197" height="1180667" />
<master id="2770" name="Double" masterType="Double" twoSides="true"
width="1644394" height="1180667" />
</masters>
<pages>
<page id="2772" logicalPage="false" double="false" leftColor="true" rightColor="true"
autoDeadline="2010-07-01T23:30:00.000Z"
number="1" sectionId="1659" sectionName="-" zoneId="1656" zoneName="-"
workstateId="6675" workstateName="Archived">
<layers>
<layer idref="2771" />
</layers>
</page>
<page id="2776" logicalPage="false" double="false" leftColor="true" rightColor="true"
autoDeadline="2010-07-01T22:30:00.000Z"
number="3" sectionId="1660" sectionName="A" zoneId="1657" zoneName="North"
workstateId="6675" workstateName="Archived">
<layers>
<layer idref="2775" />
</layers>
</page>
<page id="4123" logicalPage="false" double="false" leftColor="true" rightColor="true"
autoDeadline="2010-07-02T00:00:00.000Z"
number="4" sectionId="1660" sectionName="A" zoneId="1657" zoneName="North"
workstateId="3982" workstateName="Hold">
<layers>
<layer idref="4122" />
</layers>
</page>
</pages>
<extDocs>
</extDocs>
<layers>
<layer id="2771" name="-1 -" layerTypeId="1651" layerTypeName="Editorial" />
<layer id="2775" name="-3 -" layerTypeId="1651" layerTypeName="Editorial" />
<layer id="4122" name="A4 North" layerTypeId="1651" layerTypeName="Editorial" />
</layers>
</edition>
</objects>
The master pages width and height are in millipoints. To get centimeters instead, use:
../do.ashx?cmd=feed&name=EditionStructure&pars=unit:cm&ids=2767