XMLThis was my first time being exposed to XML. I am familiar with HTML and I had thought XML was nothing more than an older version of HTML. This week, I spent a lot of my time going through the tutorials on w3schools. Through my research, I have learned that XML is mainly implemented to store, transport and describe the data on sites, while HTML is used to format and display that data; this is possible because XML is specifically tagging the data on a page/site data, rather than tagging the sections of the page/site. Each tag is specifically linking to it's respective data. Also, XML is great when compatibility is a restraint, because it stores the data in a plain text format, which can be read by all applications. A lot of the HTML syntactical properties apply to XML, such as hierarchy structure, every element needs (should have) a closing tag, elements must be properly nested, attribute values must be in quotes, and much more. A good resource that can be used to check the syntax of an XML file is the XML Validator on the w3schools website. when writing I also learned about how XML element names may conflict with html element names. XML allows the developer to name elements as they please, but if we want to name an XML element <table>, it will conflict with the HTML element <table>. The way to get around this would be to use a prefix (explained here). XMLSchemaXML Schema is used to promote consistency of an XML document when working with a group. Is defines the structure of the XML document and its elements. XML Schema is recommended over DTD (doctype declaration) because it uses XML syntax, and supports data types & namespaces.
There are different types of elements used in XML Schema: Simple, Complex, and Data. Simple Types are defined as elements that only contain text, but is misleading, because they can actually contain all types as long as it's included in the XML Schema, or is a custom type that was defined by the developer. What makes a Simple Type "simple" is that it cannot contain attributes. Also, restrictions may be set for data held in an element; these restrictions for XML elements are referred to as "facets". This site contains a really good resource for the different constraints that may be set for the default data types. Complex elements can contain other elements and may also have attributes. Elements can be designed with an inheritance type of structure to ensure elements are used as expected. Restrictions on complex can also be set for elements that will define how elements are to be uses; this is done by the use of indicators. The following are the types of indicators that can be used in an XML Schema: Order, Occurrence, and Group. An example of an Order indicator is the sequence tag; it's used so the elements within the main element must be declared in their respective order. An example of an Occurrence indicator is minOccurs; this allows one to use multiple instances of an element if needed, for example if there was a House element, we can set it so that it has to have at least one bathroom, but could potentially have more than one. When it comes to actually writing the XML Schema, there are several different approaches one can take. We can simply write out the Schema to match the layout of the XML code, but this may become hard to read for complex xml documents. One approach that can be used is to divide elements by defining your simple elements and attributes separately, then when defining the complex elements, you can reference those predefined simple elements, which makes the schema a little easier o comprehend. Another approach would be to use Named Types; this is similar to dividing the elements, but it removes the type and restrictions from the individual elements, then is referenced when defining the complex elements. After researching XML & XML Schema, I feel much more comfortable in understanding how and when to use XML. I plan to continue researching it uses, especially how it's used in respect to RDF and the "Semantic Web".
0 Comments
Leave a Reply. |
CategoriesArchives
May 2016
|