Professional InfoPath 2003 [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Professional InfoPath 2003 [Electronic resources] - نسخه متنی

Ian Williams, Pierre Greborio

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید











Form Schemas

When you create a new blank form and add elements to the data source by using the Add button at the bottom of the task pane or you drag controls onto the form, you are creating an XML schema in the background. Each group in the data source is an XML element that can contain other elements and attributes, and each element field in the data source is an XML element that can contain attributes and data. Each attribute field is an XML attribute.


Existing XML Schemas and Other Data Sources


When you design a form for an existing industry-specific or custom schema, InfoPath creates a data source using the schema definition in the XSD file. Because an existing schema is externally defined, InfoPath doesn’t allow you to modify existing fields or groups in the data source. Depending on how restrictive the original schema is, you may not be able to add fields or groups to it either. If this is the case, you’ll have to make changes to the schema itself before you proceed.

If you design a form based on an XML document instance, InfoPath creates a schema and the data source, using the content of your document as an example. If you decide to work this way, perhaps because there is no schema available, make sure that you use an example representing as many XML elements and attributes as possible. This will ensure that InfoPath builds a form definition that is close to your needs.

When you use a database or Web service as a primary data source, InfoPath structures the form using the database schema or the description of the operations of the Web service. Again, you won’t be able to modify that part of form structure, because the data source must match the database or Web service specifications. However, you will be able to add elements and attributes to the root of the data source.

You can view some schema details by right-clicking an object in the data source and choosing Properties from the context menu. In Figure 2-3, the Details tab of the dialog box shows the properties of a group.


Figure 2-3: The Properties dialog box showing schema detail.


Schema Elements and Attributes


Throughout the book, we present diagrams for the XSF file and other XML schemas. Before you tackle the form definition structure, we’d like to include a short explanation of the symbols you’ll see in the diagrams. In case you aren’t familiar with XML Schema specification, we’ll also briefly review some key parts of schema language.

The root element of a schema is xsd:schema, including the namespace and other attributes.


<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
.
.
</xsd:schema>

You will see both xs and xsd used as the namespace prefixes in various sources. Technically it doesn’t matter what the prefix is, as long as it is consistent in an individual schema document. In this book we use the xsd prefix to be consistent with the convention in Microsoft documentation.

The most common elements are xsd:element and xsd:attribute. You will also see groups and types, used to build block definitions that can be reused in more complex schemas. Common attributes of elements are minOccurs and maxOccurs that define the cardinality of an element. The default value for both attributes is 1.

An element containing attributes or other elements is defined as xsd:complexType. Within that element the structure is usually an xsd:sequence or an xsd:choice. Often you’ll see xsd:element with a name attribute, but when an element is a child, it is usually declared separately using name. It is then referred to from the containing element using the ref attribute, as the following example shows:


<xsd:element name="scripts">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="xsf:script" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="language" type="xsf:xdScriptLanguage" use="required" />
</xsd:complexType>
</xsd:element>


Schema Diagrams


Content model is a term used to describe the set of elements and attributes contained inside another XML element. Although the XML Schema specification is explicit about how schemas should be presented in XML, there is no commonly agreed-upon format for symbols representing information in schema diagrams. Each software product has a different approach to diagramming. For these examples, we’ve used diagrams made with XMLSpy.

The diagrams show the structure and cardinality of the elements used in these structures. Attributes are not shown.


Sequence


In package consists of the sequence of files elements. Both elements are defined in the InfoPath namespace, whose prefix is xsf. The box with a plus (+) at the right indicates that there is hidden content not shown in the diagram. An arrow at the bottom left of an element indicates that it refers to a declaration elsewhere in the schema. The solid line around the elements indicates they are required elements.


Figure 2-4: The sequence model.


Choice or All


The switchlike symbol in adoAdapter, webServiceAdapter and xmlFileAdapter. Only one may occur.


Figure 2-5: The choice model.

Another way of providing a choice is to use the structure diagrammed in Figure 2-6. The symbol is for the xsd:all element that allows the contained elements to occur in any order, either once only or not at all.


Figure 2-6: The all model.


Cardinality


Cardinality expresses constraints about the minimum and maximum occurrences of elements. A dashed line around an element indicates that it is optional. The number of times it may appear is given by the text below it. In this case, 0.. means the minOccurs attribute has a value of zero and maxOccurs is unbounded (infinity). If there is no such text, the diagram is showing that it can occur only once.

errorMessage element indicates that only text content is allowed.


Figure 2-7: Cardinality.

/ 166