计算XPath前pression不工作的属性(XML:LANG)在InDesign [英] evaluate XPath expression not working for attribute (xml:lang) in indesign

查看:276
本文介绍了计算XPath前pression不工作的属性(XML:LANG)在InDesign的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用XPath前pression在Adobe InDesign,收集元素的列表。我使用的是低于code生成它。

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

以上code没有如果该元素包含XML:郎工作正常属性。

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

示例XML文件:

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

可以请你让我知道我需要让我的code为上面的XML编码工作。

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

推荐答案

InDesign中有几个问题与命名空间。他们更好地工作,当您使用ExtendScript的XML对象,如果你不使用它们(例如带/通过进口的XSLT替换它们)。

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

在我的XML命名空间提供空间声明(即使按标准的话冗余),我的InDesign CS6找到你的第例如。

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

这篇关于计算XPath前pression不工作的属性(XML:LANG)在InDesign的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆