Xml: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
= Documentation = | = Documentation = | ||
<blockquote> | <blockquote> |
Latest revision as of 20:33, 22 August 2021
Documentation
XML https://www.w3schools.com/XML/default.asp XSLT (convert XML to other formats) https://www.w3schools.com/xml/xsl_intro.asp
Components
Node/Element
<tag> <!-- node/element --> <subtag>...</subtag> <subtag>...</subtag> </tag> <tag/> <!-- empty element -->
- An Element is marked by a start/end Tag (
<tag>...</tag>
)- A collection Elements is a Node
- An empty element can be marked without an open/closing tag by placing the '/' at the end of the tag (
<tag/>
)Syntactically, nodes/elements are indistinguishable - but generally a node is used to refer to a top-level grouping of elements (at the level where it means something).
Tag
<project attrib_A="A" attrib_B="B"></project> <!-- attributes --> <project myproject></project> <!-- text --> <project/> <!-- empty element -->
- Tags may contain attributes (
<tag a="a" b="b">...</tag>
)- Tags may also be assigned a text value (
<tag "text">...</tag>
)Namespace
<tag xmlns="http://www.w3.org/foo/" <!-- define default namespace --> xmlns:x="http://www.w3.org/TR/html4/" <!-- define x: namespace --> xmlns:y="http://www.w3.org/blah/" <!-- define y: namespace --> > <x:person></x:person> <!-- becomes <http://www.w3.org/TR/html4/person> --> <y:person></y:person> <!-- becomes <http://www.w3.org/blah/person> --> <cat></cat> <!-- becomes <http://www.w3.org/foo/cat> --> </tag>
xmlns
(xml-namespace) can be declared in the root element. The when parsed, the XML element replaces the prefix with the defined URI. This is used to prevent name-clashes.There are two types of notations for keys with namespaces.
{namespace}tag
namespace#tag
Apparently, it is possible to retrieve information about the namespace from these URLS. I have not looked into this yet.
See this excellent tutorial https://www.w3schools.com/XML/schema_schema.aspSchema
It is possible to make your XML object conform to a schema listed online. I haven't fully looked into this yet.
See https://www.w3schools.com/XML/schema_schema.asp