Scribus files as XML

From Scribus Wiki
Jump to navigation Jump to search

Here is a little experiment in progress after having spent some time creating some XSLT files to process some XML files as webpages.

It seemed that maybe something similar could be done with the SLA files. What you will find is that your browser wants to find an application for .sla files, so you have to rename them as .xml files. Other than that, you also have to edit your Scribus file slightly. The beginning normally starts out like this:

<?xml version="1.0" encoding="UTF-8"?>
<SCRIBUSUTF8NEW Version="1.4.3">

What you want to do is have something like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="scribus.xsl"?>
<SCRIBUSUTF8NEW Version="1.4.3">

Once you do this, then save your myscribusfile.sla as myscribusfile.xml.

XSLT file

Here is a small experimental scribus.xsl that you might try out with one of your slightly altered Scribus files.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:template match="/">
    <html>
    <body bgcolor="#eeeeee">
      <xsl:for-each select="SCRIBUSUTF8NEW">
	<h3>This document was created using Scribus Version <xsl:value-of select="@Version" /></h3>
	<xsl:for-each select="DOCUMENT">
	  <p>This document consists of <xsl:value-of select="@ANZPAGES" /> pages, and has a width of <xsl:value-of select="@PAGEWIDTH" /> points and has a height of <xsl:value-of select="@PAGEHEIGHT" /> points. (Type: <xsl:value-of select="@PAGESIZE" />)</p>
	  <p>Its margins (L-R-T-B, in points) are <xsl:value-of select="@BORDERLEFT" />-<xsl:value-of select="@BORDERRIGHT" />-<xsl:value-of select="@BORDERTOP" />-<xsl:value-of select="@BORDERBOTTOM" />, and bleed areas (T-L-R-B, in points) are <xsl:value-of select="@BleedTop" />-<xsl:value-of select="@BleedLeft" />-<xsl:value-of select="@BleedRight" />-<xsl:value-of select="@BleedBottom" />.</p>
	  <p style="text-indent: 20px;">The default font is <xsl:value-of select="@DFONT" />, <xsl:value-of select="@DSIZE" /> points.</p>
	  <table border="1" cellspacing="0" cellpadding="3px">
	    <tr><th>Color Name</th><th>RGB</th><th>CMYK</th><th>Spot</th><th>Registr.</th></tr>
	    <xsl:for-each select="COLOR">
	      <tr><td><xsl:value-of select="@NAME" /></td><td><xsl:value-of select="@RGB" /></td><td><xsl:value-of select="@CMYK" /></td>
	      <td><xsl:if test="@Spot=0">No</xsl:if><xsl:if test="@Spot=1">Yes</xsl:if></td><td><xsl:if test="@Register=1">Yes</xsl:if></td></tr>
	    </xsl:for-each>
	  </table>
	  <hr />
	  <xsl:for-each select="PAGEOBJECT">
	    <xsl:if test="@PTYPE=2">
	    <p><strong><xsl:value-of select="@PFILE" /></strong> -- <em>Color profile: </em><strong><xsl:value-of select="@PRFILE" /></strong></p>
	    <table border="0">
	      <tr><td><img src="{@PFILE}" width="600px" /></td></tr>
	    </table>
	    <hr />
	    </xsl:if>
	    <xsl:if test="@PTYPE=4">
	      <xsl:for-each select="ITEXT">
		<table border="0" width="60%">
		  <tr><td><xsl:value-of select="@CH" /></td></tr>
		</table>
	      </xsl:for-each>
	    </xsl:if>
	  </xsl:for-each>
	</xsl:for-each>

      </xsl:for-each>
    </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

What Next?

Presuming you have your Scribus XML file and this scribus.xsl file in the same directory, just point your browser to the XML file, and see what happens.