質問

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.

役に立ちましたか?

解決

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
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top