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

PPTX
XML Schema Part 1
PPTX
Rendering XML Document
PPTX
XML - Displaying Data ith XSLT
PPT
01 xml document structure
PPT
Xml by Luqman
PPT
XML Schema
PDF
Introduction to XML
XML Schema Part 1
Rendering XML Document
XML - Displaying Data ith XSLT
01 xml document structure
Xml by Luqman
XML Schema
Introduction to XML

What's hot (19)

PPT
03 namespace
PPTX
Xml basics
PPS
Xml basics for beginning
PPTX
XML, DTD & XSD Overview
PPT
02 xml schema
PPT
XML Presentation-2
PPT
Xml Presentation-3
PPT
Xml Presentation-1
ODP
PPT
Xml theory 2005_[ngohaianh.info]_1_introduction-to-xml
PPTX
Xml schema
PPTX
Basics of XML
PDF
XML
PPT
Introduction to XML
PPTX
Xml presentation
PPT
Xml schema
PPT
00 introduction
PPTX
transforming xml using xsl and xslt
PDF
HTML and XML Difference FAQs
03 namespace
Xml basics
Xml basics for beginning
XML, DTD & XSD Overview
02 xml schema
XML Presentation-2
Xml Presentation-3
Xml Presentation-1
Xml theory 2005_[ngohaianh.info]_1_introduction-to-xml
Xml schema
Basics of XML
XML
Introduction to XML
Xml presentation
Xml schema
00 introduction
transforming xml using xsl and xslt
HTML and XML Difference FAQs
Ad

Similar to XML Schema Part 2 (20)

PPTX
PPT
Xsd examples
PPTX
Xml part4
PPTX
XML Schema
PDF
XML Schema.pdf
PPS
02 sm3 xml_xp_03
PDF
Xml schema
PPTX
Service Oriented Architecture-Unit-1-XML Schema
PPT
EXtensible Markup Language
ODP
SCDJWS 1. xml schema
PPT
Xml and DTD's
PPT
Xml1111
PDF
Web Technologies Unit 2 Print.pdf
PDF
II UNIT PPT NOTES.pdf this is the data structures
PPTX
Xml session
PPTX
XML's validation - XML Schema
PPTX
distributed system concerned lab sessions
PPTX
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
PPTX
XML Schema.pptx
Xsd examples
Xml part4
XML Schema
XML Schema.pdf
02 sm3 xml_xp_03
Xml schema
Service Oriented Architecture-Unit-1-XML Schema
EXtensible Markup Language
SCDJWS 1. xml schema
Xml and DTD's
Xml1111
Web Technologies Unit 2 Print.pdf
II UNIT PPT NOTES.pdf this is the data structures
Xml session
XML's validation - XML Schema
distributed system concerned lab sessions
Xml For Dummies Chapter 10 Building A Custom Xml Schema it-slideshares.blog...
XML Schema.pptx
Ad

More from Dudy Ali (20)

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

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
“AI and Expert System Decision Support & Business Intelligence Systems”
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
Spectroscopy.pptx food analysis technology
Advanced methodologies resolving dimensionality complications for autism neur...
The Rise and Fall of 3GPP – Time for a Sabbatical?
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Review of recent advances in non-invasive hemoglobin estimation
Spectral efficient network and resource selection model in 5G networks
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The AUB Centre for AI in Media Proposal.docx
MIND Revenue Release Quarter 2 2025 Press Release

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 dudy.fathan@eng.ui.ac.id