XForms Tutorial > I-1.3.2. instance element
XForms Model 하위 요소로 구성되어 있는 Instance 엘리먼트는 실제 데이터를 처리하는 블럭 단위의 개념이다. 서버로 데이터를 서브밋 할 경우 특정 인스턴스 단위로 데이터를 보내게 되며, 또한 응답 데이터 결과를 특정 인스턴스 단위로 매핑 등 데이터 처리를 위한 레코드 단위 개념이다. 이 인스턴스 엘리먼트 하위에는 필드(노드)들이 존재한다. 이 노드에 사용자가 입력한 데이터를 바인딩시키거나 서버로부터 응답된 데이터들을 저장하게 된다.
모델 하위에는 여러 개의 인스턴스들이 존재할 수 있으며, 일반적으로 서버와의 하나의 트랜잭션 처리를 위하여 두 개의 인스턴스, 즉 Input/Output 구조를 갖는다. 또한 공통적으로 사용되는 트랜잭션, 예를 들어 공통 코드와 같이 여러 프로그램에서 사용되는 경우에는 하나의 인스턴스를 정의하여 재사용할 수 있는 Linking Attribute 구조를 제공한다.
Common Attributes
- Common
Linking Attributes 외부 링크가 실패하면 Then XForms-Link-Exception Event에 따라 처리한다. Inline 정의와 Link 정의가 동시에 속성을 가지면 Link 정의가 우선된다.(The xForms-model-construct Event)
Sample> Input / Output 구조의 instance 구성
<?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> Instance Sample </title>
<xforms:model id="mymodel">
<xforms:instance id="instRQ">
<root xmlns="">
<code> 217531 </code>
</root>
</xforms:instance>
<xforms:instance id="instRS">
<root xmlns="">
<code />
<name />
<worker />
<bdaynum />
<cdaynum />
<cdayper />
<termnum />
<termper />
<assets />
<stocks />
<stocksp />
<apply />
<order />
</root>
</xforms:instance>
<xforms:bind id="bind_code" nodeset="instance('instRQ')/code" />
<xforms:submission id="query" ref="instance('instRQ')" replace="all" instance="instRS" method="get" mediatype="application/xml" action="http://210.219.231.49/ncrmx/nx_220.aspx?type=R" indent="1" separator="&">
</xforms:submission>
</xforms:model>
</head>
<body>
<xforms:input bind="bind_code">
<xforms:label> 코드 </xforms:label>
</xforms:input>
<xforms:submit submission="query">
<xforms:label> 조회 </xforms:label>
</xforms:submit>
</body>
</html>
- 하나의 모델(mymodel)에 두 개의 인스턴스인 instRQ와 instRS로 구성
- 서버로 데이터를 전송할 인스턴스는 instRQ 이다. submission 엘리먼트의 ref 어트리뷰트를 통해서 정의
- 서버의 결과를 매핑할 인스턴스는 instRQ 이다. submission 엘리먼트의 instance 어트리뷰트를 통해서 정의
- 참조로 Request와 Response 인스턴스를 구분하는 방법은 XForms 1.1 Draft 에 정의되어 있으며, XForms 1.0은 이를 구분하지 않는다
<xforms:model id="model1">
…(생략)…
<xforms:instance id="realData">
<root>
<human>
<userid></userid>
<username />
<tax>
<taxsource>0</taxsource>
<taxbill>0</taxbill>
<taxpermonth during="2"></taxpermonth>
</tax>
</human>
</root>
</xforms:instance>
<xforms:instance id="taxrateData" src="http://smit21.co.kr/code.xml" />
…(생략)…
댓글 없음:
댓글 쓰기