From the course: XML Essential Training
Unlock the full course today
Join today to access over 24,900 courses taught by industry experts.
Declaring complex elements
From the course: XML Essential Training
Declaring complex elements
- [Instructor] If XML were just made up of simple types, then our job would be really easy. But of course, you can define complex tag structures in XML, and we need to weigh in schema to enforce constraints on those. Complex elements are elements that don't just contain basic content like strings or numbers. They can contain other tags or have attributes. So there's two ways to do this. The easy way is to use the anyType for the type attribute in the element tag. So if you define an element and inside the type attribute, you specify anyType, it pretty much means that the content of the element is not restricted in any way. However, you can also use the complex tag type in the definition, and this is the counterpoint to the previous examples in this chapter where we were using the simpleType tag. So let's look at some examples. So how would you declare an empty element using schema? So we have here an empty element, and the way that this works is using the element tag. So to declare…
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
What is XML Schema?2m 4s
-
(Locked)
Anatomy of a schema1m 24s
-
(Locked)
Declaring simple elements7m 40s
-
(Locked)
Example: Simple elements2m 21s
-
(Locked)
Declaring complex elements4m 22s
-
(Locked)
Declaring attributes3m 51s
-
(Locked)
Example: Complex elements6m 46s
-
(Locked)
Challenge: Build a schema for BusinessCard1m 8s
-
(Locked)
Solution: Build a schema for BusinessCard4m 14s
-
(Locked)
-