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

在 word 2003 中,我可以使用上面的 xsl:template match 语句获取 word 文档 2003 的自定义属性。

如果我正在使用 Office Word 2007 或 2010,使用什么语法?

4

1 回答 1

0

自定义文档属性在一个Properties元素下维护并使用以下命名空间:

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

电话号码的自定义属性示例:

<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>

假设您在样式表中使用前缀“prop”声明命名空间,如下所示:

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

如果您保存为单个 XML 文件,您可以使用以下 XPath 找到它们:

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

你可以像这样创建一个模板匹配:

<xsl:template match="prop:Properties">
        <xsl:copy>
            <xsl:apply-templates select ="@*|node()" />
        </xsl:copy>
</xsl:template>
于 2012-01-16T02:12:21.463 回答