Page 1 of 1

Tranforming XML to XML

Posted: Thu Mar 22, 2012 4:48 pm
by sascha.koerber
Hello dear Switch Users,



we are using PowerSwitch 10 here and i am fairly new to the software and its capabilities. I read up that i´m able to use metadata stored in an XML-file in a flow.



I am curious if PowerSwitch is able not only to pickup and use the data stored in the XML but also pickup the XML, rewrite a new XML-file with changed tags/fields (Transforming/XSLT).



Is that possible? If yes: Did anyone of you already use that and give me a simple example of how it can be done?



The goal is to re-map/rename tags in very basic and short XML-file to a new (very basic) XML-file in the format that is needed.



Everything that could point me to a simple solution is appreciated very much! :-)



Thanks, Sascha

Tranforming XML to XML

Posted: Thu Mar 22, 2012 5:21 pm
by dkelly
Hello,



You can use either the XSLT configurator or a Javascript script to modify XML files. Search the forums here. There are several examples I've posted that create and modify XML using Javascript.



Dwight Kelly

Apago, Inc.

dkelly@apago.com

Tranforming XML to XML

Posted: Fri Mar 23, 2012 8:21 am
by sascha.koerber
Hello,



great! I will have a look, thanks for the info.



Sascha

Tranforming XML to XML

Posted: Tue Mar 27, 2012 3:37 pm
by dkelly
Here's an example flow that transforms XML created by Apago's PDFspy into an HTML report showing detailed information for each page.







I'll upload the flow to Crossroads World today.



Cheers,

Dwight Kelly

Apago, Inc.

dkelly@apago.com

Tranforming XML to XML

Posted: Wed Mar 28, 2012 1:53 pm
by Clive Andrews
I'll be interested to pull this one apart Dwight - it's the transformation process that eludes me.

Tranforming XML to XML

Posted: Wed Mar 28, 2012 3:53 pm
by dkelly
Clive, here's an other XSLT for PDFspy. This one generates a simple HTML report for image information.



<?xml version="1.0"?>

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

<!--

File : imageinfo.xsl

Author : Lawrence E. Freil

Date Created : May 7, 2004

Description : This file is an XSL stylesheet used as a demonstration

for pdfspy. It will output a short HTML report of all the images used in the file.

Copyright (C) - 2004 by Apago Inc.

-->



<!-- Text gobbler! -->

<xsl:template match='text()'>

</xsl:template>



<xsl:template match='/'>

<!-- If the user specified default styles in the view file, then

we will use those styles and hope he set them up nicely.

Otherwise we will default to our own style here.

-->

<HTML>

<HEAD>

<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

</META>

<TITLE><xsl:value-of select="pdfattrs/@path"/></TITLE>

</SCRIPT>

</HEAD>

<BODY TEXT="#000000" BGCOLOR="#ffffcc">

<CENTER>

<H1>Image Report</H1>

<H3>for</H3>

<H2><xsl:value-of select="pdfattrs/@path"/></H2>

</CENTER>



<STYLE TYPE="text/css">

DIV.title { background-color:teal; color:white;

font-family:Verdana,arial; font-size:14pt;

padding:2px;

}

DIV.asset { background-color:black; color:white;

font-family:Verdana,arial; font-size:14pt;

padding:2px;

}

A.titlelink { color:aqua; }

DIV.body { background-color:#ffffcc; color:Black;

padding:2px;

font-size:11pt;

}

<!-- The following turns off underlines over links -->

A { text-decoration: none; }

A:hover { color:red }

</STYLE>

<xsl:apply-templates />

</BODY>

</HTML>

</xsl:template>



<xsl:template match="pdfattrs">

<table border="0" cols="1" units="PIXELS" width="600" >

<tr><h3>Document Info</h3></tr>

<tr>PDF Version: <xsl:value-of select="./@version"/></tr>

<tr>Page Count: <xsl:value-of select="count(./page)"/></tr>

<tr>Fast Web View Enabled: <xsl:value-of select="./@linearized"/></tr>

<tr>Encrypted: <xsl:value-of select="./@encrypted"/></tr>

<tr>Tagged: <xsl:value-of select="./@tagged"/></tr>

<tr>Filesize: <xsl:value-of select="./@filesize"/> bytes</tr>

<tr/>

</table>

<xsl:apply-templates select="page" />

</xsl:template>



<xsl:template match="page">

<h3>Page #<xsl:value-of select="@id"/></h3>

<xsl:apply-templates select="images"/>

</xsl:template>



<xsl:template match="images">

<TABLE BORDER="0" UNITS="PIXELS" width="700" COLS="11">

<TR>

<TD><B>ID</B></TD>

<TD><B>BPC</B></TD>

<TD><B>Colorspace</B></TD>

<TD><B>Filter</B></TD>

<TD><B>Height</B></TD>

<TD><B>Width</B></TD>

<TD><B>x Res</B></TD>

<TD><B>y Res</B></TD>

<TD><B>x Scale</B></TD>

<TD><B>y Scale</B></TD>

<TD><B>Rotation</B></TD>

<xsl:apply-templates />

</TR>

</TABLE>

</xsl:template>



<!-- Display the info for each image. In addition to just printing

the basics also check to make sure each image is referenced in

at least one page and issue a notice if it is unreferenced

-->

<xsl:template match="image">

<TR>

<TD><xsl:value-of select="./@id"/></TD>

<TD><xsl:value-of select="./@bpc"/></TD>

<TD><xsl:value-of select="./@colorspace"/></TD>

<TD><xsl:value-of select="./@filter"/></TD>

<TD><xsl:value-of select="./@height"/></TD>

<TD><xsl:value-of select="./@width"/></TD>

<TD><xsl:value-of select="./@xres"/></TD>

<TD><xsl:value-of select="./@yres"/></TD>

<TD><xsl:value-of select="./@xscale"/></TD>

<TD><xsl:value-of select="./@yscale"/></TD>

<TD><xsl:value-of select="./@rotation"/></TD>

</TR>

</xsl:template>

</xsl:stylesheet>