XML is a markup language used for storing and transferring data. It allows data to be shared across different systems even if they have different hardware/software. XML uses tags to structure the data and is readable by both humans and machines. XML documents can be validated using DTDs or XML schemas to ensure they follow the defined structure and syntax rules. When parsing an XML document, DOM reads the entire document into memory while SAX reads nodes sequentially without storing the entire document in memory.
XML Introduction,Syntax of XML,Well formed XML Documents,XML Document Structure,Document Type Definitions,XML Namespace,XML Schemas,DOM(Document Object Model)
This document provides an introduction to XML, including its structure, syntax, and uses. It defines XML as a markup language that provides a format for structured data. It describes XML elements, attributes, and how XML documents must follow specific syntax rules to be considered well-formed. The document also discusses Document Type Definitions (DTDs), XML namespaces, XML schemas, displaying XML with CSS, and transforming XML with XSLT.
XML is a markup language similar to HTML but designed for structured data rather than web pages. It uses tags to define elements and attributes, and can be validated using DTDs or XML schemas. XML documents can be transformed and queried using XSLT and XPath respectively. SAX is an event-based parser that reads XML sequentially while DOM loads the entire document into memory for random access.
XML is a markup language similar to HTML but designed for carrying data rather than displaying it. It allows users to define their own elements and tags. XML documents use tags to describe and structure information and can be displayed using CSS or transformed using XSL. Key benefits of XML include its ability to describe hierarchical data, separate data from presentation, and enable data sharing across different systems.
This document discusses the structure and components of an XML document. It explains that an XML document consists of elements, attributes, comments, processing instructions, and a document type declaration. It describes each of these components in detail, including their purpose and general syntax. The document type declaration identifies the document and can reference an internal or external DTD that defines the valid elements and attributes.
XML Schema provides a way to formally define and validate the structure and content of XML documents. It allows defining elements, attributes, and data types, as well as restrictions like length, pattern, and value ranges. DTD is more limited and cannot validate data types. XML Schema is written in XML syntax, uses XML namespaces, and provides stronger typing capabilities compared to DTD. It allows defining simple and complex element types, attributes, and restrictions to precisely describe the expected structure and values within XML documents.
This document discusses XML and provides details about XML document structure, DTDs, validation of well-formed and valid XML documents, XML schemas, and XML namespaces. It begins by explaining the tree structure of XML documents and provides an example. It then covers DTDs, including internal and external DTDs. Next, it defines what makes an XML document well-formed and valid. XML schemas are introduced. Finally, it discusses how XML namespaces can be used to avoid name conflicts between elements.
- XML (eXtensible Markup Language) is a markup language that is designed to store and transport data. It was released in the late 1990s and became a W3C recommendation in 1998.
- XML is not meant to display data like HTML, but rather to carry data. It is designed to be self-descriptive, platform independent, and language independent. Tags are defined by the user rather than being predefined.
- A markup language uses tags to highlight or underline parts of a document. Modern markup languages like XML use tags to replace highlighting and underlining.
distributed system concerned lab sessionsmilkesa13
The document discusses XML and its features. It begins with explaining why XML is needed to standardize data exchange between different systems. It then covers key topics like XML syntax with tags, XML tree structure, creating simple XML files, using DTDs to validate XML files, and introduces more advanced concepts like XML Schema and XPath. The document provides examples to illustrate different XML structures and capabilities.
This document provides an introduction to XML, including:
- What XML is and why it was created as an extensible meta language for describing other languages.
- Basic XML rules like tags being case sensitive, elements needing closing tags, and attributes requiring quotation marks.
- Differences between XML and HTML in terms of focus, predefined tags, and use for transporting vs displaying data.
- Benefits of XML like improved web functionality through custom markup and being a meta language that describes other languages.
XML is a markup language that is used to define and store data in a structured format. It allows data to be separated from its presentation and is extensible to add new tags. An XML document must have a root element and follow syntax rules to be well-formed. It can also be validated against a DTD or schema to check that the elements and structure match the definitions.
The document discusses XML (eXtensible Markup Language), including what it is, how it differs from HTML, its basic structure and components. XML is a markup language that allows users to define their own tags to structure data. It is more flexible than HTML and allows structured storage and exchange of data. Well-formed XML documents follow syntax rules like having matching open/close tags and proper nesting of elements.
XML is a markup language used to carry and store data. It was designed to transport data rather than display it. XML tags are defined by the author rather than being predefined. XML documents form a tree structure with a root element and branching child elements. For a document to be considered valid XML, it must follow syntax rules like having matching open and close tags and properly nested elements.
This document provides an overview of XML (eXtensible Markup Language). It defines XML as a meta markup language for representing text documents and data. XML allows users to define their own tags to represent different types of information. The document discusses how XML documents form a tree structure with a root element and nested elements. It also covers XML syntax rules and parsing methods like SAX and DOM that can be used to read and manipulate XML documents.
This document provides an introduction to XML, including:
- XML stands for eXtensible Markup Language and allows users to define their own tags to provide structure and meaning to data.
- XML documents use elements with start and end tags to organize content in a hierarchical, tree-like structure. Elements can contain text or other nested elements.
- Attributes within start tags provide additional metadata about elements. Well-formed XML documents must follow syntax rules to be valid.
Web authoring refers to the process of creating, designing, and publishing content for the World Wide Web using technologies like HTML, CSS, JavaScript, and other web development tools. It involves creating web pages and websites. XML is a markup language similar to HTML that uses tags to structure and present data in a file. An XML document has a root element containing other nested elements in a hierarchical tree structure. Elements can have attributes that provide additional information.
The document describes XML Schema, including what it is, how it defines the structure of an XML document, and how it compares to DTDs. Specifically:
- An XML Schema defines the legal structure of an XML document by defining elements, attributes, data types, and more. This is similar to a blueprint for the document.
- Schemas are more powerful than DTDs as they are extensible, have more features like data typing, and are written in XML syntax.
- A key advantage of schemas is they enforce data typing, unlike DTDs which treat all content as strings. This allows for easier validation and use of data.
XML Schema defines rules for encoding documents in a machine-readable format. It allows data exchange between systems independently of programming languages. XML Schema defines elements, attributes, and data types to structure XML documents. It provides more data typing capabilities than DTDs. Namespaces are used to avoid element name conflicts between different XML vocabularies. User-defined types can restrict built-in types or create new complex types from simple types to structure application-specific data.
The document provides an overview of XML and its characteristics. It discusses how XML is used to represent semi-structured data in a machine-readable way. It describes some key components of XML, including elements, attributes, and namespaces. It also discusses XML Schema, which improves on DTDs by providing a more robust way to define the structure and constraints of XML documents.
The document provides an overview of XML and its characteristics. It discusses how XML is used to represent semi-structured data in a machine-readable way. It describes some key components of XML, including elements, attributes, and namespaces. It also discusses XML Schema, which improves on DTDs by providing a more robust way to define the structure and constraints of XML documents.
This document discusses XML and provides details about XML document structure, DTDs, validation of well-formed and valid XML documents, XML schemas, and XML namespaces. It begins by explaining the tree structure of XML documents and provides an example. It then covers DTDs, including internal and external DTDs. Next, it defines what makes an XML document well-formed and valid. XML schemas are introduced. Finally, it discusses how XML namespaces can be used to avoid name conflicts between elements.
- XML (eXtensible Markup Language) is a markup language that is designed to store and transport data. It was released in the late 1990s and became a W3C recommendation in 1998.
- XML is not meant to display data like HTML, but rather to carry data. It is designed to be self-descriptive, platform independent, and language independent. Tags are defined by the user rather than being predefined.
- A markup language uses tags to highlight or underline parts of a document. Modern markup languages like XML use tags to replace highlighting and underlining.
distributed system concerned lab sessionsmilkesa13
The document discusses XML and its features. It begins with explaining why XML is needed to standardize data exchange between different systems. It then covers key topics like XML syntax with tags, XML tree structure, creating simple XML files, using DTDs to validate XML files, and introduces more advanced concepts like XML Schema and XPath. The document provides examples to illustrate different XML structures and capabilities.
This document provides an introduction to XML, including:
- What XML is and why it was created as an extensible meta language for describing other languages.
- Basic XML rules like tags being case sensitive, elements needing closing tags, and attributes requiring quotation marks.
- Differences between XML and HTML in terms of focus, predefined tags, and use for transporting vs displaying data.
- Benefits of XML like improved web functionality through custom markup and being a meta language that describes other languages.
XML is a markup language that is used to define and store data in a structured format. It allows data to be separated from its presentation and is extensible to add new tags. An XML document must have a root element and follow syntax rules to be well-formed. It can also be validated against a DTD or schema to check that the elements and structure match the definitions.
The document discusses XML (eXtensible Markup Language), including what it is, how it differs from HTML, its basic structure and components. XML is a markup language that allows users to define their own tags to structure data. It is more flexible than HTML and allows structured storage and exchange of data. Well-formed XML documents follow syntax rules like having matching open/close tags and proper nesting of elements.
XML is a markup language used to carry and store data. It was designed to transport data rather than display it. XML tags are defined by the author rather than being predefined. XML documents form a tree structure with a root element and branching child elements. For a document to be considered valid XML, it must follow syntax rules like having matching open and close tags and properly nested elements.
This document provides an overview of XML (eXtensible Markup Language). It defines XML as a meta markup language for representing text documents and data. XML allows users to define their own tags to represent different types of information. The document discusses how XML documents form a tree structure with a root element and nested elements. It also covers XML syntax rules and parsing methods like SAX and DOM that can be used to read and manipulate XML documents.
This document provides an introduction to XML, including:
- XML stands for eXtensible Markup Language and allows users to define their own tags to provide structure and meaning to data.
- XML documents use elements with start and end tags to organize content in a hierarchical, tree-like structure. Elements can contain text or other nested elements.
- Attributes within start tags provide additional metadata about elements. Well-formed XML documents must follow syntax rules to be valid.
Web authoring refers to the process of creating, designing, and publishing content for the World Wide Web using technologies like HTML, CSS, JavaScript, and other web development tools. It involves creating web pages and websites. XML is a markup language similar to HTML that uses tags to structure and present data in a file. An XML document has a root element containing other nested elements in a hierarchical tree structure. Elements can have attributes that provide additional information.
The document describes XML Schema, including what it is, how it defines the structure of an XML document, and how it compares to DTDs. Specifically:
- An XML Schema defines the legal structure of an XML document by defining elements, attributes, data types, and more. This is similar to a blueprint for the document.
- Schemas are more powerful than DTDs as they are extensible, have more features like data typing, and are written in XML syntax.
- A key advantage of schemas is they enforce data typing, unlike DTDs which treat all content as strings. This allows for easier validation and use of data.
XML Schema defines rules for encoding documents in a machine-readable format. It allows data exchange between systems independently of programming languages. XML Schema defines elements, attributes, and data types to structure XML documents. It provides more data typing capabilities than DTDs. Namespaces are used to avoid element name conflicts between different XML vocabularies. User-defined types can restrict built-in types or create new complex types from simple types to structure application-specific data.
The document provides an overview of XML and its characteristics. It discusses how XML is used to represent semi-structured data in a machine-readable way. It describes some key components of XML, including elements, attributes, and namespaces. It also discusses XML Schema, which improves on DTDs by providing a more robust way to define the structure and constraints of XML documents.
The document provides an overview of XML and its characteristics. It discusses how XML is used to represent semi-structured data in a machine-readable way. It describes some key components of XML, including elements, attributes, and namespaces. It also discusses XML Schema, which improves on DTDs by providing a more robust way to define the structure and constraints of XML documents.
Construction Materials (Paints) in Civil EngineeringLavish Kashyap
This file will provide you information about various types of Paints in Civil Engineering field under Construction Materials.
It will be very useful for all Civil Engineering students who wants to search about various Construction Materials used in Civil Engineering field.
Paint is a vital construction material used for protecting surfaces and enhancing the aesthetic appeal of buildings and structures. It consists of several components, including pigments (for color), binders (to hold the pigment together), solvents or thinners (to adjust viscosity), and additives (to improve properties like durability and drying time).
Paint is one of the material used in Civil Engineering field. It is especially used in final stages of construction project.
Paint plays a dual role in construction: it protects building materials and contributes to the overall appearance and ambiance of a space.
Newly poured concrete opposing hot and windy conditions is considerably susceptible to plastic shrinkage cracking. Crack-free concrete structures are essential in ensuring high level of durability and functionality as cracks allow harmful instances or water to penetrate in the concrete resulting in structural damages, e.g. reinforcement corrosion or pressure application on the crack sides due to water freezing effect. Among other factors influencing plastic shrinkage, an important one is the concrete surface humidity evaporation rate. The evaporation rate is currently calculated in practice by using a quite complex Nomograph, a process rather tedious, time consuming and prone to inaccuracies. In response to such limitations, three analytical models for estimating the evaporation rate are developed and evaluated in this paper on the basis of the ACI 305R-10 Nomograph for “Hot Weather Concreting”. In this direction, several methods and techniques are employed including curve fitting via Genetic Algorithm optimization and Artificial Neural Networks techniques. The models are developed and tested upon datasets from two different countries and compared to the results of a previous similar study. The outcomes of this study indicate that such models can effectively re-develop the Nomograph output and estimate the concrete evaporation rate with high accuracy compared to typical curve-fitting statistical models or models from the literature. Among the proposed methods, the optimization via Genetic Algorithms, individually applied at each estimation process step, provides the best fitting result.
この資料は、Roy FieldingのREST論文(第5章)を振り返り、現代Webで誤解されがちなRESTの本質を解説しています。特に、ハイパーメディア制御やアプリケーション状態の管理に関する重要なポイントをわかりやすく紹介しています。
This presentation revisits Chapter 5 of Roy Fielding's PhD dissertation on REST, clarifying concepts that are often misunderstood in modern web design—such as hypermedia controls within representations and the role of hypermedia in managing application state.
The main purpose of the current study was to formulate an empirical expression for predicting the axial compression capacity and axial strain of concrete-filled plastic tubular specimens (CFPT) using the artificial neural network (ANN). A total of seventy-two experimental test data of CFPT and unconfined concrete were used for training, testing, and validating the ANN models. The ANN axial strength and strain predictions were compared with the experimental data and predictions from several existing strength models for fiber-reinforced polymer (FRP)-confined concrete. Five statistical indices were used to determine the performance of all models considered in the present study. The statistical evaluation showed that the ANN model was more effective and precise than the other models in predicting the compressive strength, with 2.8% AA error, and strain at peak stress, with 6.58% AA error, of concrete-filled plastic tube tested under axial compression load. Similar lower values were obtained for the NRMSE index.
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia
In the world of technology, Jacob Murphy Australia stands out as a Junior Software Engineer with a passion for innovation. Holding a Bachelor of Science in Computer Science from Columbia University, Jacob's forte lies in software engineering and object-oriented programming. As a Freelance Software Engineer, he excels in optimizing software applications to deliver exceptional user experiences and operational efficiency. Jacob thrives in collaborative environments, actively engaging in design and code reviews to ensure top-notch solutions. With a diverse skill set encompassing Java, C++, Python, and Agile methodologies, Jacob is poised to be a valuable asset to any software development team.
This research is oriented towards exploring mode-wise corridor level travel-time estimation using Machine learning techniques such as Artificial Neural Network (ANN) and Support Vector Machine (SVM). Authors have considered buses (equipped with in-vehicle GPS) as the probe vehicles and attempted to calculate the travel-time of other modes such as cars along a stretch of arterial roads. The proposed study considers various influential factors that affect travel time such as road geometry, traffic parameters, location information from the GPS receiver and other spatiotemporal parameters that affect the travel-time. The study used a segment modeling method for segregating the data based on identified bus stop locations. A k-fold cross-validation technique was used for determining the optimum model parameters to be used in the ANN and SVM models. The developed models were tested on a study corridor of 59.48 km stretch in Mumbai, India. The data for this study were collected for a period of five days (Monday-Friday) during the morning peak period (from 8.00 am to 11.00 am). Evaluation scores such as MAPE (mean absolute percentage error), MAD (mean absolute deviation) and RMSE (root mean square error) were used for testing the performance of the models. The MAPE values for ANN and SVM models are 11.65 and 10.78 respectively. The developed model is further statistically validated using the Kolmogorov-Smirnov test. The results obtained from these tests proved that the proposed model is statistically valid.
Design of Variable Depth Single-Span Post.pdfKamel Farid
Hunched Single Span Bridge: -
(HSSBs) have maximum depth at ends and minimum depth at midspan.
Used for long-span river crossings or highway overpasses when:
Aesthetically pleasing shape is required or
Vertical clearance needs to be maximized
2. Introduction:
• XML stands for eXtensible Markup Language and it is used
for storing and transferring data.
• XML doesn’t depend on the platform and the software
(programming language). i.e. we can able to write a program
in any language on any platform (Operating System) to send,
receive or store data using XML.
• XML is a simple document with the data, which can be used to
store and transfer data between any systems irrespective of
their hardware and software compatibilities.
• It is so much easier to read the data from XML and display it
on a GUI (graphical user interface) using markup language
like HTML.
3. HTML Vs XML
HTML(Hyper Text Markup Language) XML(eXtensible Markup Language)
HTML is not a case sensitive language XML is case sensitive language
HTML is mainly concerned with the
presentation of data
XML is mainly used for storing and
transporting the data
HTML is static XML is dynamic
In HTML the closing tag in optional In XML the closing tag is mandatory
HTML uses predefined tags such as <b>,
<br>, <img> etc.
XML uses the user-defined tags that we
create while writing the XML document.
HTML does not preserve white space. XML preserves white space.
HTML Attribute Values Quoting is
optional.
XML Attribute Values Must Always be
Quoted.
4. Simple XML document example
A XML document structure looks like this:
<root>
<child>
<subchild>.....</subchild>
</child>
<child>
<subchild>.....</subchild>
</child>
</root>
• <?xml version="1.0" encoding="UTF-8"?> is called XML Prolog.
• It is optional, however when we include it in the XML document, it
should always be the first line of the document. XML Prolog defines the
XML version and the encoding used in the XML document.
5. • The XML code can be written on a simple notepad and should be saved as
“filename.xml”.
Students.xml
<?xml version="1.0" encoding="UTF-8"?>
<students>
<student>
<num>527</num>
<name>Ravi</name>
<age>20</age>
</student>
<student>
<num>572</num>
<name>Dev</name>
<age>23</age>
</student>
</students>
6. • In the above XML document we have the details of the few students.
Here <students> is the root element, <student> is the child element and
num,name and age are sub-child elements.
Output:
7. XML Syntax
Root Element is mandatory in XML
• XML document must have a root element. A root element can
have child elements and sub-child elements.
• For example: In the following XML document, <message> is the
root element and <to>, <from>, <subject> and <text> are child
elements.
<?xml version="1.0" encoding="UTF-8"?>
<message>
<to>Durga</to>
<from>Madhu</from>
<subject>Message from teacher to Student</subject>
<text>You have an exam tomorrow at 10:00 AM</text>
</message>
8. XML Syntax Contd…
XML is case sensitive
XML is a case sensitive language.
For example:
<from>madhu</from> This is valid
<from>Prasad</FROM> This is invalid
• All letters of closing tag is in capital while all letters of opening
tag is in small, this is an example of invalid XML.
XML Prolog
<?xml version="1.0" encoding="UTF-8"?>
• This line is called the XML Prolog. It is an optional line, however
it should be the first line when you mention it. It specifies the
XML version and the encoding used in the XML document.
9. XML Syntax Contd…
Elements should not overlap
• All the elements in XML should be properly nested and they should not
overlap.
<class><teacher>Madhu</class></teacher> -->Wrong (Not nested properly)
<class><teacher>Durga</teacher></class> -->Correct (Correctly nested)
XML elements must have a closing tag
• All XML documents must have a closing tag.
<text category = message>hello</text> -->correct
<text category = message>hello -->wrong
Comments in XML
• This is how a comment should look like in XML document.
<!-- This is just a comment -->
10. XMLAttributes
• XML elements can have attributes. By the use of attributes we can
add the additional information about the element.
• XML attributes are a way to add additional data to the XML
element. Attributes contain data in form of name & value pairs.
• XML attributes are used to enhance the properties of the elements.
Note: XML attributes must always be quoted. We can use single or
double quote.
Example:
<book category="computers">
<price>1000rs</price>
<publisher>Tata McGraw Hill</publisher>
</book>
11. XMLAttributes Contd…
XML attributes vs XML Sub Elements:
• The Data can be stored in attributes or in child elements. But there are
some limitations in using attributes, over child elements.
Same information can be represented in two ways:
1st Way:
<book category="computers">
<price>1000rs</price>
<publisher>Tata McGraw Hill</publisher>
</book>
2nd Way:
<book>
<category>computers </category>
<price>1000rs</price>
<publisher>Tata McGraw Hill</publisher>
</book>
12. XMLAttributes Contd…
• In the first way category is used as an attribute and in the second
way category is used as an element.
• Both examples provide the same information but it is good practice
to avoid attribute in XML and use elements instead of attributes.
Because
• Attributes cannot contain multiple values but child elements can
have multiple values.
• Attributes cannot contain tree structure but child element can.
• Elements are easy to be handled by the programming language
compared to the attributes.
14. XML – Validation
• Validation is a process by which an XML document is validated.
• An XML document with correct syntax is known as valid XML
document.
Let‟s see few important rules to check for syntax errors.
• All XML documents must have a root element.
• XML is a case sensitive language so you should be careful with the
case while opening and closing tags.
• All XML tags must have a closing tag.
• XML attribute name should not be quoted while its value must be
quoted.
• There are two ways to check whether the XML document is valid.
1 XML DTD (Document Type Definition)
2 XML Schema
15. Document Type Definition (DTD)
• DTD stands for Document Type Definition. It is used to define
document structure with a list of legal elements and attributes.
• Document Type Definition (DTD) is a certain piece of code,
which can defines structure of XML document.
• Each DTD contains a list of elements, which specifies the rules
for structuring a given XML document.
• Each DTD specifies the relationship between root element, child
elements and sub child elements.
• An XML document is considered “well formed” and “valid” if it
is successfully validated against DTD.
16. Document Type Definition (DTD) Contd..
• DTD‟s are optional in XML, but recommended for clarity
purpose.
• DTD‟s can be declared internally (With in XML doc) and as an
external file (with in a separate file with “.dtd” extension).
Basic Building Blocks:
There are 4 building blocks to build a XML document with DTD.
those are
1.Tags
2.Elements
3.Attributes
4.Entities
17. Document Type Definition (DTD) Contd..
1. Tags:
– The XML allows the user to create own tags.Useally the tag
<tagname> is an Opening tag, </tagname> refers to its equivalent
closing tag.
Example:
<book>Let us C</book>
<author> Yashwant Kanetkar </ author >
– In XML the tags are case sensitive . And closing tag is mandatory.
– All the elements in XML should be properly nested and they
should not overlap.
18. Document Type Definition (DTD) Contd..
2. Elements in DTD:
– The DTD document is composed with various elements. These
elements are used to represent the tags in XML document.
Declaration:
<!ELEMENT name-of-element(context)>
– To declare an empty element
Syntax:
<!ELEMENT name-of-element(EMPTY)>
– To declare an element, this carries data
Syntax:
<!ELEMENT name-of-element(#PCDATA)>
(or)
<!ELEMENT name-of-element(#CDATA)>
19. Document Type Definition (DTD) Contd..
– To declare an element, this contains child elements
Syntax:
<!ELEMENT name-of-element(child-names)>
Examples:
<!ELEMENT student(id,name,age)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT age(EMPTY)>
3.Attributes:
• These are used to provide the additional information along with
elements.
• In DTD, the attributes are declared by using “ATTLIST” Keyword.
Syntax:
<! ATTLIST name-of-element name-of-attribute
attribute-type [default-value]>
20. Document Type Definition (DTD) Contd..
• In the above syntax, the field „attribute-type‟ can specifies the
following pre-defined values.
• ID:It is a value which remains unique.
• CDATA: The value supplied here is nothing but character data.
• ENTITY: The value supplied in this case is nothing but an entity.
• In the same way, the filed „default-value‟ can specifies the following
pre-defined values.
#REQUIRED: It means the value for the attribute is required.
#IMPLIED: It means the attribute is not required.
#FIXED: Here a fixed value is supplied.
Default-value: It is a default value of given attribute.
Example:
<! ATTLIST student address CDATA #REQUIRED>
21. Document Type Definition (DTD) Contd..
4. Entities:
• Some markup elements can contain complex data; these types of
elements are called as Entities.
• These are used to create small piece of data which you want you use
repeatedly throughout your schema.
Syntax:
<! ENTITY name-of-entity “value”>
Example:
<! ENTITY Book “Web Technologies”>
Used as
<author> the &Book author is Uttam K Roy</author>
22. Document Type Definition (DTD) Contd..
• DTD‟s can be declared internally (With in XML doc) and as an
external file (with in a separate file with “.dtd” extension)
Example with external DTD:
• Create a DTD for a remainder; it has following remainder as root
element and child elements-heading, to, from, message.
“remainder.dtd”
<!ELEMENT remainder(heading,to,from,message)>
<!ELEMENT heading(#PCDATA)>
<!ELEMENT to(#PCDATA)>
<!ELEMENT from(#PCDATA)>
<!ELEMENT message(#PCDATA)>
23. Document Type Definition (DTD) Contd..
“remainder.xml”
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "remainder.dtd">
<remainder>
<heading>Final Remainder</heading>
<to>Mr.Madhu</to>
<from> Ravi Gupta</from>
<message> Date of joining is 5th Feb</message>
</remainder>
Output:
24. Document Type Definition (DTD) Contd..
Example with internal DTD:
“remainderdemo.xml”
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT remainder (heading,to,from,message)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT message (#PCDATA)>
]>
<remainder>
<heading>Final Remainder</heading>
<to>Mr.Madhu</to>
<from> Ravi Gupta</from>
<message> Date of joining is 5th Feb</message>
</remainder>
25. Document Type Definition (DTD) Contd..
Example:
• Create a DTD for a catalog of four stroke engine motorbikes where
each motor bike has the following child elements: make, model,
year, color, engine, chassis number and accessories. The engine
element has child elements those are – engine number, number of
cylinders, type of fuel. The accessories elements has the attributes
like disk break, auto start and radio, each of which required and has
the possible values ‘YES’ and ‘NO’ . Entities must be declared for the
names of the popular motorbike makes.
26. Document Type Definition (DTD) Contd..
“bikecatalog.dtd”
<!ELEMENT catalog (motorbike)*>
<!ELEMENT motorbike (make, model,year,color,engine, chasis_num, accessories)>
<!ELEMENT make (#PCDATA)>
<!ELEMENT model (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT color (#PCDATA)>
<!ELEMENT engine (engine_num,cylinder_num,fuel_type)>
<!ELEMENT engine_num (#PCDATA)>
<!ELEMENT cylinder_num (#PCDATA)>
<!ELEMENT fuel_type (#PCDATA)>
<!ELEMENT chasis_num (#PCDATA)>
<!ELEMENT accessories (#PCDATA)>
<!ATTLIST accessories diskbrake (Yes|No) #REQUIRED autostart (Yes|No)
#REQUIRED radio (Yes|No) #REQUIRED>
29. XML Schema (Or) XML Schema Definition (XSD)
• XML Schema mainly used for structuring XML documents.
Similar to DTD, XML Schema is also used to check whether
the given XML document is “well formed” and “valid”.
• XML Schema can be defined root element, child elements,
their number as well as their order.
• It defines data types, default and fixed values for the
elements and attributes.
• For this purpose, it has the form of XML schema language
which is also known as Xml Schema Definition (XSD).
30. XML Schema Contd...
• XML schemas are created by using XML syntax, where
DTD use a separate syntax.
• XML Schemas specify the type of textual data that can be
used with in attributes and elements.
• If we use the XML Schema for complex and large
operations, then the processing of XML document may slow
down.
• The XML document can’t be displayed if the corresponding
schema file is absent.
31. XML Schema Contd...
Data Types in XML Schema:
• Binary data type: It includes the binary data (0’s or 1’s).
• Boolean data type: It includes either “true” or “false”.
• Number data type: There are 3 main number data types those are
o float : It contains 32-bit floating point values.
o double: It contains 64-bit floating point values.
o decimal: It includes the decimal numbers either +ve or –ve.
• Date data type: It specifies the current date (YYYY-MM-DD).
• Time data type: It specifies the current time (HH:MM:SS).
• String data type: It includes series of characters such as strings.
32. • Example: The following example is an XML schema file called
“remainder.xsd” that defines the elements of XML document.
“remainder.xsd”
<?xml version = "1.0" encoding = "UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
<xs:element name="remainder">
<xs:complextype>
<xs:sequence>
<xs:element name="to" type="xs:string">
<xs:element name="from" type="xs:string">
<xs:element name="heading" type="xs:string">
<xs:element name="msg" type="xs:string">
</xs:sequence>
</xs:complextype>
</xs:schema>
33. “remaind.xml”
<?xml version = "1.0" encoding = "UTF-8"?>
<remainder schemaLocation="remainder.xsd">
<to>Madhu</to>
<from>Durga</from>
<heading>Notice</heading>
<msg>This is My Last Remainder</msg>
</remainder>
Output:
35. • XHTML stands for EXtensible HyperText Markup
Language.
• XHTML is almost identical to HTML but it is stricter
than HTML. XHTML is HTML defined as an XML
application. It is supported by all major browsers.
• Although XHTML is almost the same as HTML but It is
more important to create your code correctly,
because XHTML is stricter than HTML in syntax and
case sensitivity.
• XHTML was developed to make HTML more
extensible and standard.
36. Let's take an example,
The following HTML code works fine in most browsers (even if
it does not follow the HTML rules).
“Bad.html”
<html>
<head>
<title>This is an example of bad HTML</title>
<body>
<h1>This is a heading
<p>This is a paragraph
</body>
The above HTML code doesn't follow the HTML rule although
it runs.
XHTML doesn't facilitate you to make badly formed code(like
missing out a closing tag).
37. There are some changes in XHTML as compared to HTML, those
are
Changes in Document Structure
• All documents must have a DOCTYPE.
• The xmlns attribute in <html> is mandatory and must specify
the xml namespace for the document.
• <html>, <head>, <title>, and <body> are mandatory with their
respective closing tags.
Changes in XHTML Tags
• All XHTML tags must be in lower case.
• All XHTML tags must be closed.
• All XHTML tags must be properly nested.
• All XHTML attributes must be in lower case.
• The name attribute has changed as id.
• XHTML attribute values must be quoted.
38. • All XHTML documents must contain a DOCTYPE declaration at the
start.
– Example: <!DOCTYPE html>
• XHTML is case-sensitive markup language. So, all the XHTML tags
and attributes must be written in lower case.
– Example:
<!-- Invalid in XHTML -->
<A Href=“file.html“>Click here</A>
<!-- Valid in XHTML -->
<a href=“file.html“>Click here </a>
• An XHTML must have an equivalent closing tag.
– Example:
<!-- Invalid in XHTML -->
<p>This paragraph not valid in XHTML.
<!-- Valid in XHTML -->
<p> This paragraph valid in XHTML. </p>
39. • All the XHTML attribute's values must be quoted.
– Example:
<!-- Invalid in XHTML -->
<img src=“xhtml.gif" width=250 height=50 />
<!-- Valid in XHTML -->
<img src=“xhtml.gif" width="250" height="50" />
• The id attribute is used to replace the name attribute. Instead of
using name = "name", XHTML prefers to use id = "id".
– Example:
<!-- Invalid in XHTML -->
<input type=“text“ name=“txtuname” />
<!-- Valid in XHTML -->
< input type=“text“ id=“txtuname” />
40. Example:
<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title of document</title>
</head> Output:
<body bgcolor=“cyan”>
some content
</body>
</html>
42. XML Parsers
• An XML parser is a software library or package that
provides interfaces for client applications to work with an
XML document.
• The XML Parser is designed to read the XML document and
create a way(interface or API) for programs to use XML.
44. DOM (Document Object Model)
• DOM is a platform that allows programs and scripts to
dynamically access and update the content and structure of a
XML documents.
• The Document Object Model (DOM) is a programming API
for HTML and XML documents. It defines the logical
structure of documents and provides interface(API) for
access documents.
• The Document Object Model can be used with any
programming language.
• DOM exposes the whole document to applications.
45. DOM (Document Object Model)
• The XML DOM defines a standard way for accessing and
manipulating XML documents. It presents an XML document
as a tree-structure.
• The tree structure makes easy to describe an XML document. A
tree structure contains root element (as parent), child element
and so on.
• The XML DOM makes a tree-structure view for an XML
document.
• We can access all elements through the DOM tree. We can
modify or delete their content and also create new elements.
47. DOM (Document Object Model)
Let's see the tree-structure representation of the above example.
48. DOM (Document Object Model)
• We need a parser to read XML document into memory and
converts into XML DOM Object that can be accesses with
any programming language (here we can use PHP).
• The DOM parser functions are part of the PHP core. There is
no installation needed to use these functions.
• To load XML document in PHP
$xmlDoc = new DOMDocument();
this statement creates an object.
$xmlDoc->load("note.xml");
this statement loads a xml file by using object.
49. DOM (Document Object Model)
These are some typical DOM properties in php:
• X -> nodeName - the name of X
• X -> nodeValue - the value of X
• X->parentNode - the parent node of X
• X->childNodes - the child nodes of X
• X->attributes - the attributes nodes of X
Where X is Node object.
“note.xml”
<?xml version="1.0" encoding="UTF-8"?>
<student>
<num>521</num>
<name>xyz</name>
<age>30</age>
</student>
50. DOM (Document Object Model)
“Note.php”
<?php
$xmlDoc = new DOMDocument();
$xmlDoc->load("note.xml");
$x = $xmlDoc->documentElement;
foreach ($x->childNodes AS $item) {
print $item->nodeValue . "<br>";
}
?>
Output:
52. XML Parsers
What is an XML parser?
– An XML parser is a software library or package
that provides interfaces for client applications to
work with an XML document.
– The XML Parser is designed to read the XML and
create a way for programs to use XML.
53. XML Parsers
Two types of parser
– SAX (Simple API for XML)
• Event driven API
• Sends events to the application as the document is read
– DOM (Document Object Model)
• Reads the entire document into memory in a tree
structure
57. SAX Implementation in Java
• Create a class which extends the SAX event handler
Import org.xml.sax.*;
import org.xml.sax.helpers.ParserFactory;
Public class SaxApplication extends HandlerBase {
public static void main(String args[]) {
}
}
59. SAX Implementation in Java
• Most important methods to parse
– void startDocument()
• Called once when document parsing begins
– void endDocument()
• Called once when parsing ends
– void startElement(...)
• Called each time an element begin tag is encountered
– void endElement(...)
• Called each time an element end tag is encountered
– void error(...)
• Called once when parsing error occurred.
60. DOM SAX
Tree model parser (Object based) (Tree
of nodes).
Event based parser (Sequence of
events).
DOM loads the file into the memory and
then parse- the file.
SAX parses the file as it reads it, i.e.
parses node by node.
Has memory constraints since it loads
the whole XML file before parsing.
No memory constraints as it does not
store the XML content in the memory.
DOM is read and write (can insert or
delete nodes).
SAX is read only i.e. can’t insert or
delete the node.
If the XML content is small, then prefer
DOM parser.
Use SAX parser when XML content is
large.
Backward and forward search is possible
for searching the tags and evaluation of
the information inside the tags.
SAX reads the XML file from top to
bottom and backward navigation is not
possible.
Slower at run time. Faster at run time.