|
next
|
 Subject: XSLT, WordML and MSXML Author: Ivan Sleeckx Date: 06 Feb 2007 09:09 AM
|
Hi,
I'm currently working on a WordML document. (XML to WordML through XSLT)
The document contains images. Now, I know XSLT doesn't like the base64 code of images, it seems you can link the document to external images.
In a stylesheet this is done like so:
<w:pict>
<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype>
<w:binData w:name="frontpagePic.PNG"></w:binData>
<v:shape id="_x0000_s1041" type="#_x0000_t75" alt="frontpagePic" style="position:absolute;left:0;text-align:left;margin-left:254pt;margin-top:439.3pt;width:285.3pt;height:284pt;z-index:-929;mso-wrap-edited:f;mso-position-horizontal-relative:page;mso-position-vertical-relative:page"
o:allowincell="f">
<v:imagedata src="C:\frontpagePic.PNG" />
<w10:wrap anchorx="page" anchory="page"/>
</v:shape>
</w:pict>
Now, I want the pictures to be changes dynamically (i.e. depending on what URL is provided in the XML. To get this done,
I've tried the following:
1. a simple src attribute
<v:imagedata>
<xsl:attribute name="src"><xsl:value-of select="myXPath/photourl" /></xsl:attribute>
</v:imagedata>
2. an enhanced url
<v:imagedata>
<xsl:attribute name="src"><xsl:value-of select="concat('file:///',myXPath/photourl)"/></xsl:attribute>
</v:imagedata>
3. a creative *cough* solution
<![CDATA[<v:imagedata src="]]><xsl:value-of select="myXPath/photourl" /><![CDATA["/>]]>
4: another creative *cough* solution
<xsl:value-of select="concat('<v:imagedata src="file:///',myXPath/photourl,'"/>')" />
All of these seem to work, when I use Stylus Studio's built-in processor or MSXML .NET. (What I do is generate a preview, save it and open the XML doc in Word.) Note: for the last two solutions Stylus Studio gives the expected warning that "the output document cannot be parsed as XML".
When I use an external MSXML processor however it doesn't seem the work. The src attrribute of the <v:imagedata> element is either empty or it's a text string (as expected).
Any ideas are welcome, since I ran out of them. Thank you.
|
|
|