在indesign中评估XPath表达式不适用于属性(xml:lang)

时间:2013-07-26 13:07:47

标签: xml applescript adobe-indesign

我在Adobe Indesign中使用Xpath表达式来收集元素列表。我使用以下代码生成它。

tell application "Adobe InDesign CS5.5"
    set user interaction level of script preferences to never interact
    tell active document
        tell XML element 1
            set myElement to evaluate XPath expression using "//para"
        end tell
    end tell
    set user interaction level of script preferences to interact with all
end tell

如果元素包含" xml:lang"上面的代码不能正常工作。属性。

示例xml文件:

<chapter>
<section>
<para xml:lang="en">This is sample para</para>
</section>
</chapter>

您能告诉我如何使我的代码能够用于上述xml编码。

1 个答案:

答案 0 :(得分:2)

InDesign在命名空间方面存在一些问题。当您使用ExtendScript的“XML”对象时,或者根本不使用它们时,它们会更好地工作(例如,在导入时通过XSLT剥离/替换它们)。

当我为xml命名空间提供名称空间声明时(即使标准的单词多余),我的InDesign CS6找到了你的段落。 E.g。

tell application "Adobe InDesign CS6"
    tell XML element 1 of active document
        make XML attribute with properties {name:"xmlns:xml", value:"http://www.w3.org/XML/1998/namespace"}
    evaluate XPath expression using "//para"
    end tell
end tell