evaluate XPath expression not working for attribute (xml:lang) in indesign

南楼画角 提交于 2019-12-11 23:41:51

问题


I am using Xpath expression in Adobe Indesign, to collect the list of elements. I am using the below code to generate it.

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

The above code does not works fine if the element contains "xml:lang" attribute.

Sample xml file:

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

could you please let me know how i need to make my code to work for the above xml coding.


回答1:


InDesign has several problems with namespaces. They better work when you use the "XML" object of ExtendScript, or if you don't use them at all (e.g. strip/replace them via an XSLT on import).

When I provided the namespace declaration for the xml namespace (even though redundant by the words of the standard), my InDesign CS6 found your para. 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


来源:https://stackoverflow.com/questions/17882142/evaluate-xpath-expression-not-working-for-attribute-xmllang-in-indesign

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!