Notizen
Web Computing
Inhalt der Notizen (1)
Seite 1
XML
designed to separate syntax from semantics with use of tags
if data is "data-centric", meaning intended for auto processing, better use a database
if data is "document-centric", meaning document is aimed at humans, XML is better
for large datasets, XML is slower due to processing
XML is an ordered and labelled tree:
character data: actual data
element: tags with set of attributes
things to know:
processing instruction: <?xml version = "1.0"?> is metadata about the document
comments: <!-- bla bla -->
empty node: <empyNode/> which is same as <emptyNode></emptyNode>
only one root node
& = &, < = <, etc with > &apos "
<![CDATA[ Everything in here is skipped by the parser ]]>
<tag xmlns:namespace = "AnyUniqueString"> creates a namespace for that tag
<?xml-stylesheet type="text/css" href="location"?> for linking a css to xml
CSS
selectors and declarations
looks like this: TAGNAME {property: value}
things to remember:
TAG1, TAG2 {declaration} means TAG1 and TAG2 will be affected by the same declaration
CSS declarations are sometimes inherited by descendants
* selects all, with more complex examples like A*D {color: red} => any D tag that is a child or later descendant of A will be affected by color red
TAG1 TAG2 {declaration} => TAG2 that is in a TAG1 but not necessarily direct child
TAG1 > TAG2 {dec} => affects TAG2 only if it's directly a child of TAG1
TAG1[att] or TAG1[att = "value"] selects tag only if tag is present or is equal to value
TAG1:pseudo examples like hover will change when hovered
DTD
<!ELEMENT name (content)> e.g. <!ELEMENT studentList (student)> <!ELEMENT student (#PCDATA)>
content can be "ANY" "EMPTY" or "#PCDATA" which stands for Parsed character data as opposed to CDATA which is (unparsed) character data
can specify how many children with *+? <!ELEMENT DVDS (dvd*)> can also use | for "or"
goes after the processing instruction in XML <!DOCTYPE name [ <!ELEMENT ...>]>
can link it instead with <!DOCTYPE SYSTEM "URI"> for private DTD or <DOCTYPE name PUBLIC "FPI" "URI"> where FPI is Formal public identifier (-/+ for standard or not standard, name of responsible for DTD, version, language) all separated by //
attributes in DTDs <!ATTLIST elementName attName type default, etc.>
many types, for default value can have #REQUIRED, #IMPLIED, #FIXED VALUE
SCHEMAS
XML Schema is an XML markup language
made because DTD is poop
DTD has no regexp, no constraints on CDATA, no support for namespaces, hard to write maintain and read large DTDs, etc.
a XML Schema is a XML doc marked up using the XML Schema markup language
the root is <xsd:schema xmlns:xsd = "URL">
schemas are made up of declarations of elements, types and attributes
<xsd:element name="foo" type="bar"/> => types can be simple types like positiveInteger, string, integer, boolean
occurrence constraints are like this <xsd:element name="foo" type ="bar" maxOccurs="unbounded" minOccurs="1"/>
sequences like this: <xsd:sequence><xsd:element .../><xsd:choice><xsd:element 1/><xsd:element 2/></xsd:choice></xsd:sequence> much like <select> tag in HTML
xsd:complexType name="foo"> <xsd:sequence> ... </xsd:sequence></xsd:complexType>
attributes: <xsd:attribute name="foo" type="simpleType"/> can also have use="required, optional or prohibited", fixed or default
DOM Document object model is an application programming interfact (API) for well formed XML docs
getDocumentElement returns root object
getChildNodes return list of child object of node object
parse checks document is well-formed (throws error if fails)
getElementsByTagName returns a NodeList of nodes having the tag
createXXXX creates nodes etc.
Node.item returns node from the list
getNodeValue returns the content of the node (string if text node)
replaceChild replaces a child node with the new supplied
appendChild links a node as a child to an element
XSLT limitations to CSS (can't restructure a doc, can't remove content, can't compute data)
Extensible stylesheet language transformation = XSLT
XSLT uses XML syntax, XPath for pattern matching, generation, suppression, duplication, moving, sorting of content.
to write:
<xsl:stylesheet version="1.0" xmlns:xsl="http..."> as root
XSLT consists of a set of templates
HTTP Hypertext transfer protocol
Stateless
8 different types of requests
GET
HEAD
POST
PUT
DELETE
TRACE
CONNECT
OPTIONS
Client side scripting:
+ lower stress on server since processing is done on client side
+ can avoid needing too many request by running script on client side for updates
- cross platform compatibility
- open source code leaves it open to anyone to see it
- careful when receiving scripts from server to execute automatically
- careful when receiving data from client side as script might have been changed
A compromise is AJAX (Asynchronous JavaScript and XML)
Informationen
- Beschreibung
- Notiz am Web Computing, erstellt von Edoardo Tassistro am 09/01/2016.
- Erstellt von
- Edoardo Tassistro
- Aufrufe
- 0
- Bewertung