Skip to main content.
home | support | download

Back to List Archive

Re: MIME Types of zipped files

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Thu Nov 10 2005 - 17:13:40 GMT
On Thu, Nov 10, 2005 at 12:07:48PM -0500, Lars D. Noodén wrote:
> On Thu, 10 Nov 2005, Bill Moseley wrote:
> >You can't have two XML declarations in the file.  Libxml2 will just
> >stop parsing.
> 
> Would this script below then work?  There is only one XML declaration and 
> then contents of the plain text file are wrapped in a wrapper as well. 
> If so then I'll try to figure out how to implement it in perl in the 
> context of SWISH::Filter

I wouldn't be so shy about trying to use existing Perl modules to do
this work.  This may work, but I find it far safer to correctly parse
the xml and extract out what you need and then correctly build a new
xml document.

But if it works for you, then that's what counts.


> 
> -Lars
> 
> 	#!/bin/sh
> 
> 	FILE=$1;
> 
> 	echo -e  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<wrapper>";
> 
> 	(echo "<mimetype>"; unzip -cq $FILE mimetype ; echo "</mimetype>"; ) 
> 	\
> 	 | grep -v '<?xml version="1.0" encoding="UTF-8"?>';
> 
> 	unzip -cq $FILE meta.xml \
> 	 | grep -v '<?xml version="1.0" encoding="UTF-8"?>';
> 
> 	unzip -cq $FILE content.xml \
> 	 | grep -v '<?xml version="1.0" encoding="UTF-8"?>';
> 
> 	echo "</wrapper>"
> 
> 
> Lars Nooden (lars@umich.edu)
> 	On the Internet, nobody knows you're a dog ...
> 	... until you start barking.
> 

-- 
Bill Moseley
moseley@hank.org

Unsubscribe from or help with the swish-e list: 
   http://swish-e.org/Discussion/

Help with Swish-e:
   http://swish-e.org/current/docs
   swish-e@sunsite.berkeley.edu
Received on Thu Nov 10 09:13:40 2005