More on Transforming InfoPath Images into WordML

Last month, I wrote about transforming InfoPath form files that contain ink picture controls into Word 2003 documents. That task involved getting the ink picture data and associated background image from the form file into WordML. This month, the task at hand was the transformation of form files with a variable number of images into WordML. This type of transformation is similar to the one regarding the ink picture, except that the number of images to be transformed at runtime is unknown.

As with the previous transformation, each image is stored as base64Binary in the form’s data source and can be output in a w:binData element within a w:pict element. The base64Binary data in the form’s data source can be found in the img element’s xd:inline attribute. The w:name attribute value of the w:binData in the WordML output, however, must be unique and match the value of the src attribute for the v:imagedata element. These attribute values require the format “wordml://<UNIQUEID>“. To achieve this format, I used xsl:attribute elements in my XSL file and output the src attribute of the input img elements as my unique IDs, as shown in the following template:

<xsl:template match="xhtml:img">
                <xsl:attribute name="w:name">wordml://<xsl:value-of select="@src"/></xsl:attribute>
                <xsl:value-of select="@xd:inline"/>
            <v:shape id=_x0000_i1025 type="#_x0000_t75">
                <xsl:attribute name="style"><xsl:value-of select="@style"/></xsl:attribute>
                    <xsl:attribute name="src">wordml://<xsl:value-of select="@src"/></xsl:attribute>

For further guidance on what the w:pict element should look like in the WordML output for different image formats, check out David Thielen’s article Completing the WordML Spec.

6 thoughts on “More on Transforming InfoPath Images into WordML

  1. Hi–I have been trying to understand this in terms of the schema for an InfoPath form…do you have a sample showing this method as part of a full XSL file? I would be very interested in seeing it–I am struggling with a WordMl XSL that needs to take images from an InfoPath form and would love to have some samples to help me along.

  2. Hi, Hilary.

    My .xsl files (the ones that contain instructions to transform InfoPath images into WordML) have proprietary data, so I cannot pass them along. However, it may be helpful to download the demo files from my TechEd 2005 presentation. In the status report solution, there is a complete .xsl file for an InfoPath-to-Word transformation. You can use that .xsl as a starting point and insert the img logic accordingly.


  3. But I still don’t seem to get this. I added a picture element to the schema. In the XSL, I added a simple "value-of select" to test and make sure the base64 was pulling over when I transformed my XML. That worked. So I added the template example above, and used "apply-template". I modified the xsl:value-of select="@xd:inline" line to xsl:value-of select="/my:status/my:Picture/@xd:inline" to reflect the path I was using…but all to no avail. Am I missing something basic here? Thanks for any help or advice….


  4. Without being able to see your XSL, I can only guess what the problem is. Here are a few random things you can check…

    1. Is the "match" statement on the xsl:template correct?
    2. Is there another xsl:template in your XSL with the same "match" statement?
    3. Within your XSL, are the parent elements of the "img" element being processed with "apply-template" rules instead of "value-of" rules?
    4. Is the path to your xd:inline attribute correct?
    5. What do the "img" src attribute values look like in your input XML? In my sample, they have the format "msoinline/c8b54be916874b76". If they are of a different format, that may be the source of the problem.

    I hope that helps…


  5. Got it!!!!! Thank you so much for your help and the examples….I would have never made it on my own.


Comments are closed.