2013-07-26 23 views
0

我在Adobe Indesign中使用Xpath表達式來收集元素列表。我正在使用下面的代碼來生成它。評估XPath表達式對於indesign中的屬性(xml:lang)不起作用

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編碼工作。

回答

2

InDesign有幾個命名空間問題。當您使用ExtendScript的「XML」對象時,或者根本不使用它們時(例如,在導入時通過XSLT去除/替換它們),它們可以更好地工作。

當我提供了xml命名空間的命名空間聲明(即使標準文字冗餘)時,我的InDesign CS6發現了您的段落。例如。

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