Question

<xsl:template match="o:CustomDocumentProperties">
        <xsl:copy>
            <xsl:apply-templates select ="@*|node()" />
        </xsl:copy>
</xsl:template>

In word 2003, I am able to get the word's document 2003's custom properties with the xsl:template match statement above.

What is the syntax to use if I am working on office Word 2007 or 2010?

Was it helpful?

Solution

Custom document properties are maintained under a Properties element and use the following namespace:

http://schemas.openxmlformats.org/officeDocument/2006/extended-properties

An example of a custom property for Telephone Number:

<pkg:part pkg:name="/docProps/custom.xml"
        pkg:contentType="application/vnd.openxmlformats-officedocument.custom-properties+xml"
        pkg:padding="256">
        <pkg:xmlData>
            <Properties
                xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"
                xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
                <property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="3"
                    name="Telephone number">
                    <vt:lpwstr>555-555-5555</vt:lpwstr>
                </property>
            </Properties>
        </pkg:xmlData>
    </pkg:part>

Assuming that you declare the namespace with the prefix "prop" in your stylesheet like this:

xmlns:prop="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"

if you save as a single XML file, you can locate them with the following XPath:

pkg:package/pkg:part/pkg:xmlData/prop:Properties

and you could create a template match like this:

<xsl:template match="prop:Properties">
        <xsl:copy>
            <xsl:apply-templates select ="@*|node()" />
        </xsl:copy>
</xsl:template>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top