August 17th, 2006

fedora 蓝色小药丸

VML and SVG

* 用 css 指定 rotation 和 flip 的做法,比起 svg 的 transform() 函数,太寒酸了
* 根元素竟然是 v:group。说起来 svg:svg 和 svg:g 都用在 svg:svg 中时,有区别么?
* 貌似没办法指定画“边长为 10pt 的正方形”,因为那个 v:group 的 coordsize 属性不容易算。不过 HTML 不是 PDF。
* 竟然可以给 v:shapetype 传参数。svg 中相应的是设定 svg:use viewBox,觉得满晦涩的。
* gradient or pttern fill 好像比 svg 弱一点
* svg 更希望用 viewBox 和 clipPath 控制缩放,而不是修改坐标系的数字
* svg 支持 xlink
* vml 那些 gradientshapeok 之类的参数很别扭
* vml 的 formulas 和 handles 真是难懂。Collapse )
http://www.w3.org/TR/NOTE-VML#h3:introduction.example
 <v:shapetype id="downArrow" coordsize="21600, 21600"
   adj="16200, 5400"
   path="m0@0l@1@0@1,0@2,0@2@0,21600@0,10800,21600xe">
  <v:stroke joinstyle="miter"/>
  <v:formulas>
   <v:f eqn="sum #0 0 0"/>
   <v:f eqn="sum #1 0 0"/>
   <v:f eqn="sum height 0 #1"/>
   <v:f eqn="sum 10800 0 #1"/>
   <v:f eqn="sum width 0 #0"/>
   <v:f eqn="prod @4 @3 10800"/>
   <v:f eqn="sum width 0 @5"/>
  </v:formulas>
  <v:path textboxrect="@1, 0, @2, @6"/>
  <v:handles>
   <v:h position="#1, #0" xrange="0, 10800" yrange="0, 21600"/>
  </v:handles>
 </v:shapetype>



update:
* 关于 formulas,是这样。每个 f 都是一个 formula,可以用 @n 来引用第 n 个公式的值。
公式 “sum A B C” 的结果是 A+B-C,而 “prod D E F” 的结果是 D*E/F,所以让人看了直想骂!
* vml 对文本的支持实在是太差了,几乎没法用{{
** spec 里面的 v-text-anchor 并没有实现,也无法用于 javascript
** css rotation 不能改变文本方向}}
* vml 的坐标计算实在是 horrible
一个 shape 既有 style.width 和 style.height,又有 coordsize。width/height 的单位是由外部的/上层元素的 coordsize 决定的,而 coordsize 决定了下层元素的 width/height。问题是,如果没有指定 coordsize,那么就继承上层的值。因此,除非很小心的计算一个 group 中每个 shape 的 coordsize,否则每个 shape 中的 path 就会有不同的单位长度。

很多东西都很别扭,不知道是怎么想的。
* 必须定义 shape, path, textbox/textpath 三个元素,且 path 与 textbox/textpath 并列为子元素,才能画出文本。path 已经背离了本意。


update 20060901:
http://www.w3.org/TR/NOTE-VML.html#_Toc416858382

Local Coordinate Space

The shape and group elements are containing blocks for their content - they define a CSS2 "block level box". Inside the containing block a local coordinate system is defined for any sub-elements using the coordsize and coordorigin attributes. All CSS2 positioning information is expressed in terms of this local coordinate space. Consequently CSS2 position attributes (left, top, width, height and so on) have no unit specifier - they are simple numbers, not CSS length quantities.

The coordsize attribute defines how many units there are along the width of the containing block. The coordorigin attribute defines the coordinate at the top left corner of the containing block. For example, if a group were defined as follows:



The containing block would be 300 pixels wide by 250 pixels high (assume that the parent element of this group was not another group). Then the coordinate system inside the containing block would range from –500.0 to 500.0 along the x-axis and –500.0 to 500.0 along the y-axis with 0.0, 0.0 right in the center of the rectangle. Any shapes inside the group are positioned and sized according to this local coordinate system. No matter how the width and height of the group is changed, the local coordinate system inside will remain the same.

The rationale behind this is that the vectors defining a shape can be specified in a local coordinate system. If the containing block for the shape is changed, the outline of the shape will be automatically scaled to the new box. Similarly, shapes within the local ordinate system of a group will be automatically scaled if the containing block of the group changes.

It is important to note that the containing block does not establish a clipping region. Sub-elements and paths may be drawn outside the boundaries of the containing block. The containing block merely serves to map the local coordinate space to the page space.


这一段是说,group 和 shape 都可以为子元素设定坐标系。但是这里没有提到 shapetype。实际上,shapetype 不仅为子元素设定坐标系,也为实例 shape 设定坐标系。另外,为子元素设定坐标系,包括 width.height.top.left 几个 css 属性,以及 path.textboxrect 等 xml 属性。shape 既可以把 path 作为 vml 属性,也可以作为子元素,因此同一个 path 字符串在属性和子元素中的含义不同。

spec 给的例子容易让人误解,或者让我这样的人火大。在 group 中先设定一个 coordsize,紧接着又在 shapetype 中设定一个 coordsize。group/@coordsize 只在 shapetype/@path 中应用了,其他地方都是 shapetype/@coordsize,包括 shapetype/path/@textboxrect 和实例 shape/@style.width 等等。不是说不行,而是很难让人理解,尤其是在例子中有错的时候:第一个错误就是子元素 path/@textboxrect 使用了 group/@coordsize,导致文本没有画出来,这种时候怎么会怀疑到例子本身是错的!

例子第二个错误是后面两个 shape/@style.width 之类的都错了,第三个 shape/@path 写成了 shape/@v,都改掉的话,才能看到最终的结果。


现在还在用上个世纪的技术,被抛弃的技术,今天还要玩一天。一定是疯了。为啥就没有好用的,可以随产品发布的 svg plugin 呢,这是产品经理的失误吧?
没办法,legacy 代码太多了,懂 vml 的人也比 svg 多,毕竟开发/培养了这么久。



update:
看到一个不错的 BLOG: http://www.ziyuehome.com 因为主人挺老实的
Collapse )
fedora 蓝色小药丸

zz:XPath20



XPath 2.0 is an expression language that allows the processing of values conforming to the data model defined in [XQuery/XPath Data Model (XDM)]. The data model provides a tree representation of XML documents as well as atomic values such as integers, strings, and booleans, and sequences that may contain both references to nodes in an XML document and atomic values. The result of an XPath expression may be a selection of nodes from the input documents, or an atomic value, or more generally, any sequence allowed by the data model.

The name of the language derives from its most distinctive feature, the path expression, which provides a means of hierarchic addressing of the nodes in an XML tree.

XPath is designed to be embedded in a host language such as [XSLT 2.0] or [XQuery]. XPath has a natural subset that can be used for matching (testing whether or not a node matches a pattern); this use of XPath is described in [XSLT 2.0].

XQuery Version 1.0 is an extension of XPath Version 2.0.

XPath also depends on and is closely related to the following specifications:

* [XQuery/XPath Data Model (XDM)] defines the data model that underlies all XPath expressions.
* [XQuery 1.0 and XPath 2.0 Formal Semantics] defines the static semantics of XPath and also contains a formal but non-normative description of the dynamic semantics that may be useful for implementors and others who require a formal definition.
* The type system of XPath is based on [XML Schema].
* The built-in function library and the operators supported by XPath are defined in [XQuery 1.0 and XPath 2.0 Functions and Operators].



http://www.w3.org/TR/xpath20/


下午把 Functions & Operators 列表抄了一份,觉得 date time 相关的 fn/op 定义真是太别扭了。集合操作,还有 uri/QName 操作是没有用过的。
那么 XPath20 本身只是讲定位吗?