SOA - WS-Topic 3-II
SOA - WS-Topic 3-II
SOA - WS-Topic 3-II
Dr.Chamara
Dept. of ICT, Faculty of Technology
University of Sri Jayewardenepura
doc4.xml is well-formed
But not valid
Error at line 2, column 6: no declaration found for element 'foo'
CDATA
Character Data
All text in an XML document will be parsed by the parser, but
CDATA text will be ignored by the parser. Tags inside the text will
NOT be treated as markup.
INTERNAL DTD DECLARATION
EXTERNAL DTD DECLARATION
The file “doc3.dtd" which contains the DTD:
doc3.dtd
EMPTY ELEMENTS
ELEMENTS WITH ANY CONTENTS
EXAMPLE
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bibliography [
<!ELEMENT bibliography (book+)>
<!ELEMENT book (title, author*, publisher?, year?, section*)>
<!ATTLIST book ISBN CDATA #REQUIRED>
<!ATTLIST book price CDATA #IMPLIED>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT i (#PCDATA)>
<!ELEMENT content (#PCDATA|i)*>
<!ELEMENT section (title, content?, section*)>
]>
<bibliography>
<book ISBN="gg">
<title>'Home'</title>
<author>'Disanayeke'</author>
<publisher>'SJP'</publisher>
</book>
<book ISBN="gk">
<title>'Campus'</title>
<author>'Kumara'</author>
</book>
</bibliography>
ENTITIES
Entities are variables used to define shortcuts to standard
text or special characters.
Entity references are references to entities
Entities can be declared internal or external
INTERNAL ENTITY DECLARATION
Syntax:
DTD Example:
XML Example:
<author>&writer;©right;</author>
EXTERNAL ENTITY DECLARATION
Syntax:
<!ENTITY entity-name SYSTEM "URI/URL">
DTD Example:
<!ENTITY writer SYSTEM
"https://www.disney.com/entities.dtd">
<!ENTITY copyright SYSTEM
"https://www.disney.com/entities.dtd">
XML Example:
<author>&writer;©right;</author>
QUESTION: WRITE A SAMPLE XML FOR
THE FOLLOWING DTD.
indicates that the elements and data types used in the schema
come from the "http://www.w3.org/2001/XMLSchema"
namespace. It also specifies that the elements and data types
that come from the "http://www.w3.org/2001/XMLSchema"
namespace should be prefixed with xs:
XML SCHEMA
The following part:
<lastname>Silva</lastname>
<age>36</age>
<dateborn>1970-03-27</dateborn>
Occurrence indicators
maxOccurs indicator
minOccurs indicator
ORDER INDICATORS
Order indicators are used to define the order of the
elements.
<xs:element name="student">
<xs:complexType>
<order_indicator>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</order_indicator>
</xs:complexType>
</xs:element>
Name Conflicts
In XML, element names are defined by the developer. This
often results in a conflict when trying to mix XML
documents from different XML applications.
This XML carries HTML table information
<table>
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>
<table>
<name>African Coffee Table</name>
<width>80</width>
<length>120</length>
</table>
If these XML fragments were added together, there would be
a name conflict. Both contain a <table> element, but the
elements have different content and meaning.
A user or an XML application will not know how to handle
these differences.
In HTML, we know (and all the browsers know!) that the <a>
element defines a hyperlink. However, this is not how it works
with XML. In XML documents, you can use whatever element
names you want - therefore it is impossible for browsers to
predict what hyperlink elements will be called in XML
documents.
<homepages xmlns:xlink="http://www.w3.org/1999/xlink">
<homepage xlink:type="simple"
xlink:href="http://www.w3schools.com">Visit
W3Schools</homepage>
<homepage xlink:type="simple"
xlink:href="http://www.w3.org">Visit W3C</homepage>
</homepages>
XPointer
href="http://www.example.com/cdlist.xml#id('rock').child(5,item)"
QUESTIONS
Task 1: Write down internal DTD, external DTD and XML schema
<addressBook>
<gender>male</gender>
</friend>
<gender>female</gender>
</friend>
<address>Galle</address>
<gender>male</gender>
</friend>
</addressBook>