0

与此问题类似:使用 Altova Stylevision 固定定位

但我想用 XPath 表达式动态定位。这应该是可能的,但我无法让它工作。

我有这个 XML 示例:

<?xml version="1.0" encoding="UTF-8"?>
<strings>
    <p lp="200">first string</p>
    <p lp="300">second string</p>
</strings>

我在我的设计中添加了用户定义模板的内容/strings/p,现在我希望它由“lp”属性定位。

对于该任务,我将 XPath 表达式/strings/p/@ld作为值添加到公共子组中的左侧属性,以便布局框指向添加的模板。但结果是布局框定位到左边缘,表明 StyleVision 将其视为 0(零)

我还尝试了这个表达式/strings/p/concat(@lp,'px'),以便它评估为附加“px”的数字,因为设计是以像素为单位设置的,但我得到相同的结果 - XPath 表达式被评估为 0。
小屏幕截图:http: //i.imgur.com /yPzzz.png

谁能帮助如何使用 XPath 在 StyleVision 中定位模板?

4

1 回答 1

0

It seems that it is not layout box that needs to be positioned, but content inside layout box, whatever that is (depending on design).
In that case, dynamic (and absolute) positioning can be done by setting common positioning style attributes to XPath expression as in later example (by concatenation of unit /strings/p/concat(@lp,'px') as that's what program expects). And it is important to set "position" style attribute to "absolute" (which may seem like overkill demand as I initially already set that my design is in "absolute positioning mode")

After being able to see expected result, I was soon disappointed that this kind of style positioning is valid only for HTML output. Other output formats does not respect it, and I would be happy to be proven wrong.

In reality, often HTML is not desired output, but some more flexible format. And in such situations I suggest this excellent tool: XHTML2RTF, which transforms XHTML to RTF in regards to positioning elements in XHTML file. Further RTF can be converted to any common format

As conclusion, for my initial problem, using StyleVision was wrong approach. It complicated things while result was limited. For absolute positioning output from XML source I would suggest either scripting language or simple XSLT if possible, and XHTML2RTF tool afterwards

于 2012-09-23T12:21:16.863 回答