- Processing XML documents with Oracle JDeveloper 11g
- Deepak Vohra
- 302字
- 2021-08-06 17:22:06
Chapter 2. Creating an XML Schema
While XML has become the standard medium for exchanging data, it's the XML schema that defines the structure, content, and semantics of the XML documents. Before you create an XML document that conforms to an XML schema, create the XML schema with the procedure explained in this chapter. Why is it better to start off from an XML schema instead of directly creating the XML document without a schema? Consider a shipping company that sends XML documents containing details on a cargo shipment to a client. If the XML documents are not based on an XML schema, the shipping company might send XML documents containing different sets of elements and attributes. The client won't be able to interpret the XML documents if the XML documents contain different sets of elements and attributes. If the XML documents are based on an XML schema, the client would receive similar XML documents and be able to interpret them. An XML schema makes XML documents understandable to the different parties involved.
JDeveloper 11g provides various wizards for processing an XML schema. In the New Gallery a new schema file may be created. To construct a schema, select XML schema components from the schema Component Palette. A schema may be registered from the Tools menu. Subsequently, an XML document may be created from a registered schema.
In this chapter we shall create an XML schema in JDeveloper 11g. We shall register an XML document in JDeveloper and subsequently create an XML document instance from the XML schema. The example XML schema document that we shall create is catalog.xsd
and is listed here:
<?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="catalog" type="catalogType"/> <xsd:complexType name="catalogType"> <xsd:sequence> <xsd:element ref="journal" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:element name="journal" type="journalType"/> <xsd:complexType name="journalType"> <xsd:sequence> <xsd:element ref="article" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="title" type="xsd:string"/> <xsd:attribute name="publisher" type="xsd:string"/> <xsd:attribute name="edition" type="xsd:string"/> </xsd:complexType> <xsd:element name="article" type="articleType"/> <xsd:complexType name="articleType"> <xsd:sequence> <xsd:element name="title" type="xsd:string"/> <xsd:element name="author" type="xsd:string"/> </xsd:sequence> <xsd:attribute name="section" type="xsd:string"/> </xsd:complexType> </xsd:schema>
The XML document instance that we shall generate from the schema is catalog.xml
and is listed as follows:
<?xml version="1.0" encoding="utf-8"?> <catalog> <journal title="Oracle Magazine" publisher="Oracle Publishing" edition="September-October 2008"> <article section="Features"> <title>Share 2.0</title> <author>Alan Joch</author> </article> </journal> <journal title="Oracle Magazine" publisher="Oracle Publishing" edition="March-April 2008"> <article section="Oracle Developer"> <title>Declarative Data Filtering</title> <author>Steve Muench</author> </article> </journal></catalog>
- Moodle 2.0 E/Learning Course Development
- Enhancing Microsoft Content Management Server with ASP.NET 2.0
- Premiere Pro 2022短視頻剪輯、調(diào)色與特效制作實(shí)戰(zhàn)(全彩微課版)
- AutoCAD Civil 3D 2018 場(chǎng)地設(shè)計(jì)實(shí)例教程
- 新編三維CAD習(xí)題集
- 邊做邊學(xué):Photoshop+CorelDRAW綜合實(shí)訓(xùn)教程
- Microsoft Dynamics GP 2010 Reporting
- Premiere pro CC中文版自學(xué)視頻教程
- Microsoft SharePoint 2010 and Windows PowerShell 2.0: Expert Cookbook
- AI寫實(shí)人物繪畫關(guān)鍵詞圖鑒(Stable Diffusion版)
- 中文版3ds Max 2014基礎(chǔ)培訓(xùn)教程
- 攝影師的后期課:人像調(diào)色篇
- 攝影師的后期課:RAW格式技法篇
- 剪輯師寶典:視頻剪輯思維與案例實(shí)戰(zhàn)
- Instant MDX Queries for SQL Server 2012