XForms Tutorial > I-1.2.3. Single-Node Binding Attributes

Form Control또는 Action Module과 XPath에 의해 정의된 instance data node 간에 Binding 방법을 정의하는 속성을 말한다. 일반적으로 모델에 instance data를 정의한 후 화면의 컨트롤과 연결을 하고자 할 경우 사용되며, 그 방법은 다음 그림과 같이 크게 두 가지가 있다.

[그림] ref attribute를 이용한 Single Node Binding
[그림] bind attribute를 이용한 Single Node Binding


Attribute
  • ref : XPath 1.0 spec에 따라 표현 (Binding Expression)한다. bind attribute와 함께 있을 경우 무시된다.
  • model : XForm Model selector. 바인딩하는 Element와 연관시키기 위해 XForms Model의 ID를 명시 해야 한다. Ref와 마찬가지로 model attribute 역시 bind attribute와 함께 있을 경우 무시된다.
  • bind : bind element 참조하기 바란다.


  • Comment
  • ref나 bind 중 반드시 하나는 필요하고, 함께 있을 경우에는 bind 속성에 따른다.
  • XForms 프로세서에서는 model IDREF값이 참조하는 ID가 model element가 아니거나 또는 bind IDREF 값이 참조하는 ID가 bind element가 아닌 경우 xforms-binding exception Event을 발생시킨다.

    First-node rule Single-node Binding Attribute 값으로 size가 1보다 큰 node-set을 선택한 경우에는 도큐먼트 순서에 따라 node-set의 첫 번째 node가 선택된다

    Sample> Ref를 통한 Single-Node Binding
    <?xml version="1.0" encoding="euc-kr"?>
    <html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:xforms="http://www.w3.org/2002/xforms" 
     xmlns:ev="http://www.w3.org/2001/xml-events">
    <head>
    <title> Single-Node Binding </title>
     <xforms:model id="mymodel">
      <xforms:instance id="instRQ">
       <root xmlns="">
        <code> 217531 </code>
       </root>
      </xforms:instance>
     </xforms:model> 
    </head>
     
    <body>
    <xforms:input ref="code">
      <xforms:label> 코드 </xforms:label>
     </xforms:input>
    </body>
    </html>
  • input 컨트롤을 instance code node에 ref attribute를 통해 Single-node Binding 하는 예제이다


  • Sample> Bind를 통한 Single-Node Binding
    <?xml version="1.0" encoding="euc-kr"?>
    <html xmlns="http://www.w3.org/1999/xhtml" 
     xmlns:xforms="http://www.w3.org/2002/xforms" 
     xmlns:ev="http://www.w3.org/2001/xml-events">
    <head>
    <title> Single-Node Binding </title>
     <xforms:model id="mymodel">
      <xforms:instance id="instRQ">
       <root xmlns="">
        <code> 217531 </code>
       </root>
      </xforms:instance>
     </xforms:model>
     <xforms:bind id="bind_code" nodeset="code" />
    </head>
     
    <body>
    <xforms:input bind="bind_code" ref=”code”>
      <xforms:label> 코드 </xforms:label>
     </xforms:input>
    </body>
    </html>
  • iinput 컨트롤을 instance code node에 Bind 엘리먼트를 통해 Single-node Binding 하는 예제이다.
  • 만약 input 컨트롤에서 Single-node Binding을 위하여 bind 및 ref 어트리뷰트를 동시에 사용했을 경우 bind 어트리뷰트가 우선한다.
  • 댓글 없음: