Set ContentPanel-Property based on input-xml

Nov 16, 2009 at 11:27 AM


All my XPath-Placeholders are placed inside a ContentControl. What I want to achieve is, that if an attribute in my input-xml has a specific value, I want to lock editing the ContentControl - which is in fact only one additional element per ContentControl in the document.xml.

I think the best way to do this, is to modify the XmlQueryProcessor.xslt - but how? Do you have any suggestions how to do that?

my input-xml:

<?xml version="1.0" encoding="utf-8" ?>
<sample xmlns="urn:sampleorder">
 <fullname locked="true">Thomas Sample</fullname>

my word-template, the bold element is the one, I want to insert, if the locked-attribute above is true:

          <w:id w:val="6397526"/>
          <w:lock w:val="contentLocked"/>
            <w:docPart w:val="DefaultPlaceholder_22675703"/>
          <w:customXml w:uri="urn:fleXdoc" w:element="UseContext">
              <w:attr w:name="path" w:val="o:sample/o:person"/>
            <w:customXml w:uri="urn:fleXdoc" w:element="ValueOf">
                <w:attr w:name="path" w:val="o:fullname"/>


Nov 16, 2009 at 1:31 PM

Hello Dani,

To support such scenario, you will have to modify the xml of the Word-document manually, since Word doesn't support that. If you are sure that's what you want, then you can take two approaches to modify the content control properties:

  1. Do it from within the fleXdoc xslt (XmlQueryProcessor.xslt)
    • Advantage: Relative xpath (eg. UseContext and ForEach work)
    • Disadvantage: You need to modify the xslt, which makes it hard to maintain after the original fleXdoc-version gets updated
  2. Create your own class and call it from the PreProcess-function (BaseTemplateProcessor).
    • Advantage: Easy to maintain and keep working with future updates of fleXdoc, easy to modify the document because you can use the OOXML SDK
    • Disadvantage: No context node, so xpath must be absolute (just like ImportTemplate and IncludeTemplate)

Decide for yourself which approach suits best. Personally I would chose the second, since requires only minimal changes to fleXdoc-code. And maybe in the future fleXdoc will support configurable template processors (this is why I split up the classes BaseTemplateProcessor and fleXdocTemplateProcessor).