Scribus files as XML: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
m (added geishi and bolded for emphasis)
No edit summary
 
Line 22: Line 22:
===XSLT file===
===XSLT file===
Here is a small experimental ''scribus.xsl'' that you might try out with one of your slightly altered Scribus files.
Here is a small experimental ''scribus.xsl'' that you might try out with one of your slightly altered Scribus files.
<pre>
<syntaxhighlight lang="xml">
<xsl:stylesheet version="1.0"
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Line 66: Line 66:
   </xsl:template>
   </xsl:template>
</xsl:stylesheet>
</xsl:stylesheet>
</pre>
</syntaxhighlight>


===What Next?===
===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.
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.

Latest revision as of 02:26, 30 November 2013

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

This page talks about using a modified SLA file, renaming it as an XML file, then using XSLT to interpret it for a browser.

I've also begun a separate project to generate a new XML file using Scripter: Scribus XML using Scripter. The main advantage is a file-wide customization of the XML.

But meanwhile, back at this page's topic...

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.