cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
JamesG New Member
New Member

XLST is useful for more than just JDF transforms

XLST is also good for converting XML data into CSV file for use with MAX. Example below is to drive the ESv3-04 Biz Cards workflow:

 

XML Data below:  

<?xml version="1.0" encoding="utf-8"?>
<Jobs>
<customer ref="xerox"> 
<name>C:\FFCore EasyStarts v3\Sample Files\BC PolishPottery Palmer - Portrait Bleed.pdf</name> 
<id>bleed</id> 
<box>9.25903E+11</box>
<type>BC</type>
<group>a</group> 
</customer>

<customer ref="xerox"> 
<name>C:\FFCore EasyStarts v3\Sample Files\BC Ventosa Raines - Landscape No Bleed.pdf</name> 
<id> </id> 
<box>9.25903E+11</box>
<type>BC</type>
<group>b</group> 
</customer>

<customer ref="xerox"> 
<name>C:\FFCore EasyStarts v3\Sample Files\BC Players Besson - Landscape Bleed.pdf</name> 
<id> </id> 
<box>9.25903E+11</box>
<type>BC</type>
<group>d</group> 
</customer>
<customer ref="xerox"> 
<name>C:\FFCore EasyStarts v3\Sample Files\BC PolishPottery Martin - Portrait Bleed.pdf</name> 
<id> </id> 
<box>9.25903E+11</box>
<type>BC</type>
<group>d</group> 
</customer>

<customer ref="xerox"> 
<name>C:\FFCore EasyStarts v3\Sample Files\BC PolishPottery Naiyeer - Portrait Bleed.pdf</name> 
<id> </id> 
<box>9.25903E+11</box>
<type>BC</type>
<group>d</group> 
</customer>

<customer ref="xerox"> 
<name>C:\FFCore EasyStarts v3\Sample Files\BC Ventosa Wallace - Landscape No Bleed.pdf</name> 
<id> </id> 
<box>9.25903E+11</box>
<type>BC</type>
<group>d</group> 
</customer>

<customer ref="xerox"> 
<name>C:\FFCore EasyStarts v3\Sample Files\BC Ventosa York - Landscape No Bleed.pdf</name> 
<id> </id> 
<box>9.25903E+11</box>
<type>BC</type>
<group>d</group> 
</customer>
</Jobs>

 

Output CSV data required below:

C:\FFCore EasyStarts v3\Sample Files\BC PolishPottery Palmer - Portrait Bleed.pdf,bleed,9.25903E+11,BC,a
C:\FFCore EasyStarts v3\Sample Files\BC Ventosa Raines - Landscape No Bleed.pdf, ,9.25903E+11,BC,b
C:\FFCore EasyStarts v3\Sample Files\BC Players Besson - Landscape Bleed.pdf, ,9.25903E+11,BC,d
C:\FFCore EasyStarts v3\Sample Files\BC PolishPottery Martin - Portrait Bleed.pdf, ,9.25903E+11,BC,d
C:\FFCore EasyStarts v3\Sample Files\BC PolishPottery Naiyeer - Portrait Bleed.pdf, ,9.25903E+11,BC,d
C:\FFCore EasyStarts v3\Sample Files\BC Ventosa Wallace - Landscape No Bleed.pdf, ,9.25903E+11,BC,d
C:\FFCore EasyStarts v3\Sample Files\BC Ventosa York - Landscape No Bleed.pdf, ,9.25903E+11,BC,d

  

XLST to do the work below:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" encoding="utf-8"/>
<xsl:template match="Jobs">

<!-- next 2 lines add in 1st record as field names --> 
<!-- <xsl:text>Name,Id,Box,Type,Group </xsl:text>
<xsl:text>&#10;</xsl:text>
-->

<xsl:for-each select="customer">
<xsl:value-of select="name"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="id"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="box"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="type"/> 
<xsl:text>,</xsl:text>
<xsl:value-of select="group"/>
<xsl:text>&#10;</xsl:text>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

  

If you see an 'emoticon' in the XSLT above, this should be an ':' and an 'o'. Some system make it into an a smiley!

 

An example .BAT file to use XALAN is called transformXML.BAT and is in the FreeFlow directory. I copied the above XML and XSLT I created, into that directory for testing. For production a more elegent solution would be needed!

 

James

Labels (4)
Tags (1)
0 Kudos
1 Reply
Account Deactivated

Re: XLST is useful for more than just JDF transforms

Note: JamesG - edited the post to put the data as code using the Code icon.png icon in the editing toolbar.

0 Kudos