I got a jpeg to appear but not given the $image param. On trying this I get
a blank jpeg 500/500.

XSL:
--------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml";
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint";
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office">
        <xsl:param name="image"/>
        <xsl:match
pattern="/w:wordDocument/w:body/wx:sect/w:p/w:r/w:pict/v:shape/v:imagedata[@
o:title=$image]">
                <xsl:variable name="height" select="100"/>
                <xsl:variable name="width" select="100"/>
                <svg:svg xmlns:svg="http://www.w3.org/SVG";>
                        <svg:g>
                                <svg:image
xmlns:xlink="http://www.w3.org/1999/xlink"; height="{$height}px"
width="{$width}px">
                                        <xsl:attribute
name="xlink:href"><xsl:text>data:image/png;base64,</xsl:text><xsl:value-of
select="../../w:binData"/></xsl:attribute>
                                </svg:image>
                        </svg:g>
                </svg:svg>
        </xsl:match>
</xsl:stylesheet>
------------


XML (snipped)
------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?mso-application progid="Word.Document"?>
<w:wordDocument
xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml";
xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:w10="urn:schemas-microsoft-com:office:word"
xmlns:sl="http://schemas.microsoft.com/schemaLibrary/2003/core";
xmlns:aml="http://schemas.microsoft.com/aml/2001/core";
xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint";
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" w:macrosPresent="no"
w:embeddedObjPresent="no" w:ocxPresent="no" xml:space="preserve">
        ...
        <w:body>
                <wx:sect>
                        <w:p>
                                <w:r>
                                        <w:pict>
                                                ...
                                                <w:binData
w:name="wordml://02000001.jpg">
                                                <!--base64 data -->
                                                </w:binData>
                                                <v:shape id="_x0000_i1025"
type="#_x0000_t75" style="width:415.5pt;height:311.25pt">
                                                        <v:imagedata
src="wordml://02000001.jpg" o:title="Tulips"/>
                                                </v:shape>
                                        </w:pict>
                                </w:r>
                        </w:p>
                        ...
                </wx:sect>
        </w:body>
</w:wordDocument>
-------

Also, I have never used "xsl:match" before only "xsl:template match" and
can't find it in any xslt books. Is this an extension function in cocoon?


Regards,

Linc



-----Original Message-----
From: Simon Mieth [mailto:[EMAIL PROTECTED] 
Sent: Friday, 3 September 2004 4:59 AM
To: [EMAIL PROTECTED]
Subject: Re: WordML image to jpeg/gif via cocoon?

On Thu, 02 Sep 2004 15:41:05 +0200
"Gerald Aichholzer" <[EMAIL PROTECTED]> wrote:

> On Thu, 2 Sep 2004 20:59:51 +0800, Lincoln Mitchell 
> <[EMAIL PROTECTED]>  wrote:
> 
> > How would I convert an image in wordML to a jpeg or gif via Cocoon?
> >
> > So far I have only found this .net solution by Oleg Tkachenko:"In 
> > WordML images are embedded into document
> > (Base64 encoded). So when producing HTML, images have to be decoded 
> > and serialized out as external files to link from the generated 
> > HTML. This cannot be done in pure XSLT  1.0.
> > But it's piece of cake using extensions, e.g. take a look at my 
> > sample implementation for .NET:
> > http://www.tkachenko.com/blog/archives/000195.html";
> >
> 
> Hi Lincoln,
> 
> here are some ideas which came just to my minds:
> 
> - convert your WordML to HTML with links for images
>    (similar to the following):
> 
>    <html>
>      ...
>      <img
>      src="http://localhost:8888/getimg.html?imgno=nn"/>...
>    </html>
> 
> - getimg.html is a pipeline which returns the nn'th image
>    from the WordML document (of course you need some
>    method to specify the WordML document, too).
> 
>    Because this is base64 encoded you need to decode it.
>    I don't know if this will be possible using XSLT only,
>    because also in the sample provided by you an external
>    function is used.
> 

Hi,

I know nothing about WordML, but i have worked with OpenOffice FlatXML.
There are the images embedded as base64-data elements too.

The solutions was like Gerald, create a pipeline where you can extract the
image. You will need to pass the document and an image-ID like:

<map:match pattern="test/*/*.jpg">
  <map:generate src="docs/{1}.wordml"/>
  <map:transform src="xsl/wordml2svg.xsl">
     <map:parameter name="image" value="{2}"/>
  </map:transform>
  <map:serialize type="svg2jpeg"/>
</map:match>


You need an XSL-Stylesheet, which extract the image data and create a
SVG-document. The SVG-image-element can hold the data as base64 endcoded
xlink.

Here is a snipped
<xsl:match pattern="[EMAIL PROTECTED] = $image]"> <svg:svg> <svg:g>
  <svg:image xmlns:xlink="http://www.w3.org/1999/xlink";
   width="3cm" height="2cm">     
  <xsl:attribute name="xlink:href">       
    <xsl:text>data:image/png;base64,</xsl:text> 
   <!-- pass the base64 here -->  
     <xsl:value-of
       select="yourBase64"/>          
    </xsl:attribute>
  </svg:image>
</svg:g>
</svg:svg>
</xsl:match>

The SVG-serializer will generate the image. Inside your HTML you can
generate a relative uri too, like <image src="foo/01111.jpg"/> if your page
is foo.html from foo.wordml. 


Best Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to