You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by John Moylan <jo...@nua-tech.com> on 2002/06/13 16:09:20 UTC

decoding base64 tiff files embedded in XML

Hi,

I'm new to this list and to Cocoon2, however I need to develop an application which transforms NewsML feeds into regular HTML for browsing. Easy you say, right? Anyway the part I'm am having difficulty with is in converting base64 embedded tiff images into png on the fly.
	I don't know much about Java. I have a one liner in Perl which decodes the tiff from the shell prompt:

	perl -MMIME::Base64 -ne 'print decode_base64($_)' </home/john/tiff.64 >j.tiff

	and an one liner which uses imagemagick's convert from the shell:
	
	convert j.tiff j.png

Can I somehow use turn one or both, of these one liners into sitemap generators (is that the right term.) or is their any easier/better way. I can preprocess my XML files from the command line, but that does not seem like a very elegant/manageable solution.







---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: decoding base64 tiff files embedded in XML

Posted by KOZLOV Roman <r-...@opencascade.com>.
Hi John,

To omit xml declaration by standard way you can use top level xsl element xsl:output:

    <xsl:output omit-xml-declaration = "yes"/>

However if you use your stylesheet as a source for a transformer in cocoon then this method doesn't work and in this case you can configure appropriate serializer in sitemap with the following line:

    <omit-xml-declaration>yes</omit-xml-declaration>


Best regards
Roman

John Moylan wrote:

> Not knowing how to write a reader or a serializer I think I'm going to have to run a batch process, something like the following in BASH/Perl and sabletron (because it was installed.)
>
> DIR=/usr/local/jakarta-tomcat-3.3.1/webapps/cocoon/content
>
> ls $DIR/*.xml > /tmp/xmlfiles
>
>         for i in `cat /tmp/xmlfiles`
>                 do
>                         sabcmd $DIR/base64tiff.xsl $i $i.64tiff
>                         perl -MMIME::Base64 -ne 'print decode_base64($_)' <$i.64tiff >$i.tiff
>                         convert $i.64tiff $i.jpg
>                 done
>
> My stylesheet -simple
>
> <?xml version="1.0"?>
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="/">
>                 <xsl:value-of select="//ContentItem/Encoding[@Notation='base64']/DataContent"/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> However, all of my tiff base64 files have <?xml version="1.0" encoding="UTF-8"?> prepended to them - I'm curios as to wether or not their is a way to avoid this at the top of xsl processed files using standard xslt techniques?
>
> On Thu, Jun 13, 2002 at 03:50:16PM +0100, Ricardo Trindade wrote:
> > From: "Ricardo Trindade" <Ri...@myrealbox.com>
> > To: <co...@xml.apache.org>
> > Subject: RE: decoding base64 tiff files embedded in XML
> > Date: Thu, 13 Jun 2002 15:50:16 +0100
> > X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0)
> >
> > there is a transformer that removes some nodes from XML and changes them
> > with links. I think you could use this aproach.
> >
> > For the actual transformation I imagine you can use some library that does
> > that without a lot of effort... sun used to have a java imaging package...
> >
> > You could code a sitemap element (perhaps a reader) to call shell commands,
> > but you would loose all portability and gain dependencies on external
> > stuff(perl,etc..)
> >
> > -----Original Message-----
> > From: John Moylan [mailto:john@nua-tech.com]
> > Sent: quinta-feira, 13 de Junho de 2002 15:09
> > To: cocoon-users@xml.apache.org
> > Subject: decoding base64 tiff files embedded in XML
> >
> >
> > Hi,
> >
> > I'm new to this list and to Cocoon2, however I need to develop an
> > application which transforms NewsML feeds into regular HTML for browsing.
> > Easy you say, right? Anyway the part I'm am having difficulty with is in
> > converting base64 embedded tiff images into png on the fly.
> >       I don't know much about Java. I have a one liner in Perl which decodes the
> > tiff from the shell prompt:
> >
> >       perl -MMIME::Base64 -ne 'print decode_base64($_)' </home/john/tiff.64
> > >j.tiff
> >
> >       and an one liner which uses imagemagick's convert from the shell:
> >
> >       convert j.tiff j.png
> >
> > Can I somehow use turn one or both, of these one liners into sitemap
> > generators (is that the right term.) or is their any easier/better way. I
> > can preprocess my XML files from the command line, but that does not seem
> > like a very elegant/manageable solution.
> >
> >
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail:     <co...@xml.apache.org>
> > For additional commands, e-mail:   <co...@xml.apache.org>
> >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question  has not already been answered in the
> > FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> >
> > To unsubscribe, e-mail:     <co...@xml.apache.org>
> > For additional commands, e-mail:   <co...@xml.apache.org>
> >
>
> --
> John G. Moylan
>
> _________________________________________________________________________
> pub  1024D/A5B03E9B 2002-04-24 John G Moylan <jo...@nua-tech.com>
>      Key fingerprint = 4859 3C71 2CA6 99CF 62D9  5960 6613 5049 A5B0 3E9B
> sub  1024g/0EF26151 2002-04-24 [expires: 2003-04-24]
>
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: decoding base64 tiff files embedded in XML

Posted by John Moylan <jo...@nua-tech.com>.
Not knowing how to write a reader or a serializer I think I'm going to have to run a batch process, something like the following in BASH/Perl and sabletron (because it was installed.)




DIR=/usr/local/jakarta-tomcat-3.3.1/webapps/cocoon/content

ls $DIR/*.xml > /tmp/xmlfiles

        for i in `cat /tmp/xmlfiles`
                do
                        sabcmd $DIR/base64tiff.xsl $i $i.64tiff
                        perl -MMIME::Base64 -ne 'print decode_base64($_)' <$i.64tiff >$i.tiff
                        convert $i.64tiff $i.jpg
                done




My stylesheet -simple

<?xml version="1.0"?>

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

<xsl:template match="/">
                <xsl:value-of select="//ContentItem/Encoding[@Notation='base64']/DataContent"/>
</xsl:template>

</xsl:stylesheet>




However, all of my tiff base64 files have <?xml version="1.0" encoding="UTF-8"?> prepended to them - I'm curios as to wether or not their is a way to avoid this at the top of xsl processed files using standard xslt techniques?





On Thu, Jun 13, 2002 at 03:50:16PM +0100, Ricardo Trindade wrote:
> From: "Ricardo Trindade" <Ri...@myrealbox.com>
> To: <co...@xml.apache.org>
> Subject: RE: decoding base64 tiff files embedded in XML
> Date: Thu, 13 Jun 2002 15:50:16 +0100
> X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2910.0)
> 
> there is a transformer that removes some nodes from XML and changes them
> with links. I think you could use this aproach.
> 
> For the actual transformation I imagine you can use some library that does
> that without a lot of effort... sun used to have a java imaging package...
> 
> You could code a sitemap element (perhaps a reader) to call shell commands,
> but you would loose all portability and gain dependencies on external
> stuff(perl,etc..)
> 
> -----Original Message-----
> From: John Moylan [mailto:john@nua-tech.com]
> Sent: quinta-feira, 13 de Junho de 2002 15:09
> To: cocoon-users@xml.apache.org
> Subject: decoding base64 tiff files embedded in XML
> 
> 
> Hi,
> 
> I'm new to this list and to Cocoon2, however I need to develop an
> application which transforms NewsML feeds into regular HTML for browsing.
> Easy you say, right? Anyway the part I'm am having difficulty with is in
> converting base64 embedded tiff images into png on the fly.
> 	I don't know much about Java. I have a one liner in Perl which decodes the
> tiff from the shell prompt:
> 
> 	perl -MMIME::Base64 -ne 'print decode_base64($_)' </home/john/tiff.64
> >j.tiff
> 
> 	and an one liner which uses imagemagick's convert from the shell:
> 
> 	convert j.tiff j.png
> 
> Can I somehow use turn one or both, of these one liners into sitemap
> generators (is that the right term.) or is their any easier/better way. I
> can preprocess my XML files from the command line, but that does not seem
> like a very elegant/manageable solution.
> 
> 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
> 
> 
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <co...@xml.apache.org>
> For additional commands, e-mail:   <co...@xml.apache.org>
> 

-- 
John G. Moylan

_________________________________________________________________________
pub  1024D/A5B03E9B 2002-04-24 John G Moylan <jo...@nua-tech.com>
     Key fingerprint = 4859 3C71 2CA6 99CF 62D9  5960 6613 5049 A5B0 3E9B
sub  1024g/0EF26151 2002-04-24 [expires: 2003-04-24]


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: decoding base64 tiff files embedded in XML

Posted by Ricardo Trindade <Ri...@myrealbox.com>.
there is a transformer that removes some nodes from XML and changes them
with links. I think you could use this aproach.

For the actual transformation I imagine you can use some library that does
that without a lot of effort... sun used to have a java imaging package...

You could code a sitemap element (perhaps a reader) to call shell commands,
but you would loose all portability and gain dependencies on external
stuff(perl,etc..)

-----Original Message-----
From: John Moylan [mailto:john@nua-tech.com]
Sent: quinta-feira, 13 de Junho de 2002 15:09
To: cocoon-users@xml.apache.org
Subject: decoding base64 tiff files embedded in XML


Hi,

I'm new to this list and to Cocoon2, however I need to develop an
application which transforms NewsML feeds into regular HTML for browsing.
Easy you say, right? Anyway the part I'm am having difficulty with is in
converting base64 embedded tiff images into png on the fly.
	I don't know much about Java. I have a one liner in Perl which decodes the
tiff from the shell prompt:

	perl -MMIME::Base64 -ne 'print decode_base64($_)' </home/john/tiff.64
>j.tiff

	and an one liner which uses imagemagick's convert from the shell:

	convert j.tiff j.png

Can I somehow use turn one or both, of these one liners into sitemap
generators (is that the right term.) or is their any easier/better way. I
can preprocess my XML files from the command line, but that does not seem
like a very elegant/manageable solution.







---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


RE: decoding base64 tiff files embedded in XML

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: John Moylan [mailto:john@nua-tech.com]
> 
> Hi,
> 
> I'm new to this list and to Cocoon2, however I need to develop an
application
> which transforms NewsML feeds into regular HTML for browsing. Easy you
say,
> right? Anyway the part I'm am having difficulty with is in converting
base64
> embedded tiff images into png on the fly.
>
> 	I don't know much about Java. I have a one liner in Perl which
decodes
> the tiff from the shell prompt:
> 
> 	perl -MMIME::Base64 -ne 'print decode_base64($_)'
</home/john/tiff.64
> >j.tiff
> 
> 	and an one liner which uses imagemagick's convert from the
shell:
> 
> 	convert j.tiff j.png
> 
> Can I somehow use turn one or both, of these one liners into sitemap
> generators (is that the right term.)

There are many approaches you can take. Depends on what level of
reusability of your components you want to achieve and details of input
format (never seen NewsML...).

If input is XML with data and images intermixed, use fragment extractor.

If input is XML, one way is to write serializer which takes input XML
with base64 encoded image and outputs image. It can also convert image
from tiff to png (using some Java image manipulation library).

If input is not XML, then you should write reader, which will read
base64, decode it, and write image as output (converting as necessary).


Vadim


> or is their any easier/better way. I can
> preprocess my XML files from the command line, but that does not seem
like a
> very elegant/manageable solution.
> 


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>