SlideShare a Scribd company logo
Q5M1 - XML Dudy Fathan Ali S.Kom
XML Schema
Q5M1 - XML
Dudy Fathan Ali, S.Kom (DFA)
2015
CEP - CCIT
Fakultas Teknik Universitas Indonesia
Declaring Attributes in a Schema
Q5M1 - XML Dudy Fathan Ali S.Kom
Attributes in an XML schema are declared in the same way as
elements.
Declaring attributes in an XML schema facilitates the assimilation of
information for an XML document.
Attribute declarations can be defined in two ways:
Simple type definitions: Facilitates local validation of the
attribute information.
Global attribute declarations: Enables reuse of attributes.
Attribute
Attribute Element
Q5M1 - XML Dudy Fathan Ali S.Kom
In XSD, an attribute for a user-defined element is declared
using the attribute element.
The syntax for declaring an attribute in XSD is:
<attribute name="attributename"
ref="attributename"
type="datatypename" use="value" value="value">
</attribute>
The attribute element contains attributes that are used to
further qualify and restrict the scope and usage of the user-
defined attribute.
Attribute Element
Q5M1 - XML Dudy Fathan Ali S.Kom
The attribute element consists of the following attributes:
name
ref
type
use
Attribute Element
Q5M1 - XML Dudy Fathan Ali S.Kom
The attribute element consists of the following attributes:
name
ref
type
use
Is used to specify the name of a user-defined attribute.
Must be used when the schema element is the parent
element of the attribute element.
Colon (:) should not be included in the value of the
name attribute.
Attribute Element
Q5M1 - XML Dudy Fathan Ali S.Kom
The attribute element consists of the following attributes:
name
ref
type
use
Is used to refer to a user-defined attribute declared either
in the same or in any other XSD document.
Attribute Element
Q5M1 - XML Dudy Fathan Ali S.Kom
The attribute element consists of the following attributes:
name
ref
type
use
Takes a value that specifies the data type of the user-
defined attribute.
<xsd:attribute name="PRODUCTID"
type="xsd:string">
OR
<xsd:attribute name="PRODID" type="myID">
Attribute Element
Q5M1 - XML Dudy Fathan Ali S.Kom
The attribute element consists of the following attributes:
name
ref
type
use Specifies the way in which an attribute can be used in an
XML document.
Values that can be assigned to the use attribute are
optional, default, required, and fixed.
<xsd:attribute name="baseprice“ type="xsd:integer“ use="optional" />
<xsd:attribute name="baseprice“ type="xsd:integer“ default="25" />
<xsd:attribute name="baseprice“ type="xsd:integer“ use="required" />
<xsd:attribute name="baseprice“ type="xsd:integer" fixed="600“ />
Attribute Element
Q5M1 - XML Dudy Fathan Ali S.Kom
Global Attribute
Q5M1 - XML Dudy Fathan Ali S.Kom
Global attributes are declared outside all element declarations.
Global attributes facilitate attribute reusability.
Global attributes can be associated with simple and complex
data types.
Global attributes have the schema element as the parent
element.
<xsd:schema>
<xsd:attribute name="NAME" type="xsd:string"/>
</xsd:schema>
Global Attribute
Q5M1 - XML Dudy Fathan Ali S.Kom
A global attribute can be reused from anywhere in a schema
<xsd:element name="BOOK" type="BOOKTYPE"/>
<xsd:complexType name="BOOKTYPE">
……..
<xsd:attribute ref="NAME"/>
……..
</xsd:complexType>
<xsd:element name="AUTHOR" type="AUTHORTYPE"/>
<xsd:complexType name="AUTHORTYPE">
……..
<xsd:attribute ref="NAME"/>
……..
</xsd:complexType>
Global Attribute
Q5M1 - XML Dudy Fathan Ali S.Kom
XSD Restrictions
Q5M1 - XML Dudy Fathan Ali S.Kom
In order to restrict values that can be assigned to an attribute
or element:
Declare the attribute or element and associate it with a user-
defined simple data type.
Create a simple data type by using the XSD simpleType
element.
Use the XSD restriction element within the simpleType
element to restrict the values that can be assigned to the
elements or attributes that use the simple data type.
Restricting Values
Q5M1 - XML Dudy Fathan Ali S.Kom
Example Code
Restrictions on Values
Q5M1 - XML Dudy Fathan Ali S.Kom
Consider of this following code, The following example defines an element called "age"
with a restriction. The value of age cannot be lower than 0 or greater than 150:
Restrictions on Values
Q5M1 - XML Dudy Fathan Ali S.Kom
Consider of this following code, The following example defines an element called "gender"
with a restriction. The only acceptable value is Male OR Female:
Restrictions for Datatypes
Q5M1 - XML Dudy Fathan Ali S.Kom
Source : w3schools.com
Q5M1 - XML Dudy Fathan Ali S.Kom
Thank You!
Dudy Fathan Ali S.Kom
dudy.fathan@eng.ui.ac.id

More Related Content

What's hot (19)

PPT
03 namespace
Baskarkncet
 
PPTX
Xml basics
Kumar
 
PPS
Xml basics for beginning
Ahmad Awsaf-uz-zaman
 
PPTX
XML, DTD & XSD Overview
Pradeep Rapolu
 
PPT
02 xml schema
Baskarkncet
 
PPT
XML Presentation-2
Sudharsan S
 
PPT
Xml Presentation-3
Sudharsan S
 
PPT
Xml Presentation-1
Sudharsan S
 
ODP
XML
Osama Qunoo
 
PPT
Xml theory 2005_[ngohaianh.info]_1_introduction-to-xml
Ông Thông
 
PPTX
Xml schema
Akshaya Akshaya
 
PPTX
Basics of XML
indiangarg
 
PDF
XML
Prabu U
 
PPT
Introduction to XML
Fazli Kabashi
 
PPTX
Xml presentation
Miguel Angel Teheran Garcia
 
PPT
Xml schema
Harry Potter
 
PPT
00 introduction
Baskarkncet
 
PPTX
transforming xml using xsl and xslt
Hemant Suthar
 
PDF
HTML and XML Difference FAQs
Umar Ali
 
03 namespace
Baskarkncet
 
Xml basics
Kumar
 
Xml basics for beginning
Ahmad Awsaf-uz-zaman
 
XML, DTD & XSD Overview
Pradeep Rapolu
 
02 xml schema
Baskarkncet
 
XML Presentation-2
Sudharsan S
 
Xml Presentation-3
Sudharsan S
 
Xml Presentation-1
Sudharsan S
 
Xml theory 2005_[ngohaianh.info]_1_introduction-to-xml
Ông Thông
 
Xml schema
Akshaya Akshaya
 
Basics of XML
indiangarg
 
XML
Prabu U
 
Introduction to XML
Fazli Kabashi
 
Xml presentation
Miguel Angel Teheran Garcia
 
Xml schema
Harry Potter
 
00 introduction
Baskarkncet
 
transforming xml using xsl and xslt
Hemant Suthar
 
HTML and XML Difference FAQs
Umar Ali
 

Similar to XML Schema Part 2 (20)

PPTX
Xml part4
NOHA AW
 
PPT
Xsd examples
Bình Trọng Án
 
PDF
XSD Incomplete Overview Draft
Pedro De Almeida
 
PPTX
XML Schema
Kumar
 
PPTX
XML SCHEMAS
SaraswathiRamalingam
 
PPTX
XML-Schema-Elements_Types_Attributes.pptx
AkshayKumar100378
 
PPTX
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
VijiPriya Jeyamani
 
PDF
Xml schema
Dr.Saranya K.G
 
PDF
XML Schema.pdf
KGSCSEPSGCT
 
PPTX
Xml schema
sana mateen
 
PPTX
Service Oriented Architecture-Unit-1-XML Schema
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
PDF
Xml schema
Prabhakaran V M
 
PPTX
Web Service Workshop - 3 days
David Ionut
 
DOCX
Introduction to xml schema
Abhishek Kesharwani
 
PPT
Introduction to xml
Return on Intelligence
 
PPT
Introduction to XML
Return on Intelligence
 
DOC
Xsd
xavier john
 
PPT
Xml Session No 1
Saif Ullah Dar
 
PPTX
XML Schema.pptx
JohnsonDcunha1
 
Xml part4
NOHA AW
 
Xsd examples
Bình Trọng Án
 
XSD Incomplete Overview Draft
Pedro De Almeida
 
XML Schema
Kumar
 
XML-Schema-Elements_Types_Attributes.pptx
AkshayKumar100378
 
IPT Chapter 3 Data Mapping and Exchange - Dr. J. VijiPriya
VijiPriya Jeyamani
 
Xml schema
Dr.Saranya K.G
 
XML Schema.pdf
KGSCSEPSGCT
 
Xml schema
sana mateen
 
Service Oriented Architecture-Unit-1-XML Schema
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
Xml schema
Prabhakaran V M
 
Web Service Workshop - 3 days
David Ionut
 
Introduction to xml schema
Abhishek Kesharwani
 
Introduction to xml
Return on Intelligence
 
Introduction to XML
Return on Intelligence
 
Xml Session No 1
Saif Ullah Dar
 
XML Schema.pptx
JohnsonDcunha1
 
Ad

More from Dudy Ali (20)

PDF
Understanding COM+
Dudy Ali
 
PDF
Distributed Application Development (Introduction)
Dudy Ali
 
PPTX
Java CRUD Mechanism with SQL Server Database
Dudy Ali
 
PPTX
Network Socket Programming with JAVA
Dudy Ali
 
PPTX
Review Materi ASP.NET
Dudy Ali
 
PPTX
Pengantar XML
Dudy Ali
 
PPTX
Pengantar XML DOM
Dudy Ali
 
PPTX
Pengantar ADO.NET
Dudy Ali
 
PPTX
Database Connectivity with JDBC
Dudy Ali
 
PPTX
Algorithm & Data Structure - Algoritma Pengurutan
Dudy Ali
 
PPTX
Algorithm & Data Structure - Pengantar
Dudy Ali
 
PPTX
Object Oriented Programming - Value Types & Reference Types
Dudy Ali
 
PPTX
Object Oriented Programming - Inheritance
Dudy Ali
 
PPTX
Object Oriented Programming - File Input & Output
Dudy Ali
 
PPTX
Object Oriented Programming - Constructors & Destructors
Dudy Ali
 
PPTX
Object Oriented Programming - Abstraction & Encapsulation
Dudy Ali
 
PPTX
Web Programming Syaria - Pengenalan Halaman Web
Dudy Ali
 
PPTX
Web Programming Syaria - PHP
Dudy Ali
 
PPTX
Software Project Management - Project Management Knowledge
Dudy Ali
 
PPTX
Software Project Management - Proses Manajemen Proyek
Dudy Ali
 
Understanding COM+
Dudy Ali
 
Distributed Application Development (Introduction)
Dudy Ali
 
Java CRUD Mechanism with SQL Server Database
Dudy Ali
 
Network Socket Programming with JAVA
Dudy Ali
 
Review Materi ASP.NET
Dudy Ali
 
Pengantar XML
Dudy Ali
 
Pengantar XML DOM
Dudy Ali
 
Pengantar ADO.NET
Dudy Ali
 
Database Connectivity with JDBC
Dudy Ali
 
Algorithm & Data Structure - Algoritma Pengurutan
Dudy Ali
 
Algorithm & Data Structure - Pengantar
Dudy Ali
 
Object Oriented Programming - Value Types & Reference Types
Dudy Ali
 
Object Oriented Programming - Inheritance
Dudy Ali
 
Object Oriented Programming - File Input & Output
Dudy Ali
 
Object Oriented Programming - Constructors & Destructors
Dudy Ali
 
Object Oriented Programming - Abstraction & Encapsulation
Dudy Ali
 
Web Programming Syaria - Pengenalan Halaman Web
Dudy Ali
 
Web Programming Syaria - PHP
Dudy Ali
 
Software Project Management - Project Management Knowledge
Dudy Ali
 
Software Project Management - Proses Manajemen Proyek
Dudy Ali
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 

XML Schema Part 2

  • 1. Q5M1 - XML Dudy Fathan Ali S.Kom XML Schema Q5M1 - XML Dudy Fathan Ali, S.Kom (DFA) 2015 CEP - CCIT Fakultas Teknik Universitas Indonesia
  • 2. Declaring Attributes in a Schema Q5M1 - XML Dudy Fathan Ali S.Kom Attributes in an XML schema are declared in the same way as elements. Declaring attributes in an XML schema facilitates the assimilation of information for an XML document. Attribute declarations can be defined in two ways: Simple type definitions: Facilitates local validation of the attribute information. Global attribute declarations: Enables reuse of attributes. Attribute
  • 3. Attribute Element Q5M1 - XML Dudy Fathan Ali S.Kom In XSD, an attribute for a user-defined element is declared using the attribute element. The syntax for declaring an attribute in XSD is: <attribute name="attributename" ref="attributename" type="datatypename" use="value" value="value"> </attribute> The attribute element contains attributes that are used to further qualify and restrict the scope and usage of the user- defined attribute.
  • 4. Attribute Element Q5M1 - XML Dudy Fathan Ali S.Kom The attribute element consists of the following attributes: name ref type use
  • 5. Attribute Element Q5M1 - XML Dudy Fathan Ali S.Kom The attribute element consists of the following attributes: name ref type use Is used to specify the name of a user-defined attribute. Must be used when the schema element is the parent element of the attribute element. Colon (:) should not be included in the value of the name attribute.
  • 6. Attribute Element Q5M1 - XML Dudy Fathan Ali S.Kom The attribute element consists of the following attributes: name ref type use Is used to refer to a user-defined attribute declared either in the same or in any other XSD document.
  • 7. Attribute Element Q5M1 - XML Dudy Fathan Ali S.Kom The attribute element consists of the following attributes: name ref type use Takes a value that specifies the data type of the user- defined attribute. <xsd:attribute name="PRODUCTID" type="xsd:string"> OR <xsd:attribute name="PRODID" type="myID">
  • 8. Attribute Element Q5M1 - XML Dudy Fathan Ali S.Kom The attribute element consists of the following attributes: name ref type use Specifies the way in which an attribute can be used in an XML document. Values that can be assigned to the use attribute are optional, default, required, and fixed. <xsd:attribute name="baseprice“ type="xsd:integer“ use="optional" /> <xsd:attribute name="baseprice“ type="xsd:integer“ default="25" /> <xsd:attribute name="baseprice“ type="xsd:integer“ use="required" /> <xsd:attribute name="baseprice“ type="xsd:integer" fixed="600“ />
  • 9. Attribute Element Q5M1 - XML Dudy Fathan Ali S.Kom
  • 10. Global Attribute Q5M1 - XML Dudy Fathan Ali S.Kom Global attributes are declared outside all element declarations. Global attributes facilitate attribute reusability. Global attributes can be associated with simple and complex data types. Global attributes have the schema element as the parent element. <xsd:schema> <xsd:attribute name="NAME" type="xsd:string"/> </xsd:schema>
  • 11. Global Attribute Q5M1 - XML Dudy Fathan Ali S.Kom A global attribute can be reused from anywhere in a schema <xsd:element name="BOOK" type="BOOKTYPE"/> <xsd:complexType name="BOOKTYPE"> …….. <xsd:attribute ref="NAME"/> …….. </xsd:complexType> <xsd:element name="AUTHOR" type="AUTHORTYPE"/> <xsd:complexType name="AUTHORTYPE"> …….. <xsd:attribute ref="NAME"/> …….. </xsd:complexType>
  • 12. Global Attribute Q5M1 - XML Dudy Fathan Ali S.Kom
  • 13. XSD Restrictions Q5M1 - XML Dudy Fathan Ali S.Kom In order to restrict values that can be assigned to an attribute or element: Declare the attribute or element and associate it with a user- defined simple data type. Create a simple data type by using the XSD simpleType element. Use the XSD restriction element within the simpleType element to restrict the values that can be assigned to the elements or attributes that use the simple data type.
  • 14. Restricting Values Q5M1 - XML Dudy Fathan Ali S.Kom Example Code
  • 15. Restrictions on Values Q5M1 - XML Dudy Fathan Ali S.Kom Consider of this following code, The following example defines an element called "age" with a restriction. The value of age cannot be lower than 0 or greater than 150:
  • 16. Restrictions on Values Q5M1 - XML Dudy Fathan Ali S.Kom Consider of this following code, The following example defines an element called "gender" with a restriction. The only acceptable value is Male OR Female:
  • 17. Restrictions for Datatypes Q5M1 - XML Dudy Fathan Ali S.Kom Source : w3schools.com
  • 18. Q5M1 - XML Dudy Fathan Ali S.Kom Thank You! Dudy Fathan Ali S.Kom [email protected]