XML Code Snippets

Provides framework templates and code snippets related to XML (eXtensible Markup Language). Includes XML 1.0 and 1.1, XML Schema, XSLT, XInclude, XML Events, XLink and a working draft of XFrames.

General editor notes or advisories within the snippets are contained within angle quotations: « ».

Version 2.0.0.1. Released: 2008-09-02.

References: XML 1.0, XML Namespaces 1.0, xml-stylesheet Processing Instruction, XML 1.1, XML Namespaces 1.1, xml:base, xml:id, Xinclude, XML-Events, XLink, XFrames.

<?xml version="1.0" encoding="UTF-8"?> <documentElement> <element attribute="value"> <emptyElement attribute="value"/> </element> </documentElement>
<?xml version="1.1" encoding="UTF-8"?> <documentElement> <element attribute="value"> <emptyElement attribute="value"/> </element> </documentElement>
<!--  -->
<?pitarget commands ?>
<![CDATA[ A CDATA section ]]>
<?xml-stylesheet type="" href="" media="" alternate="«yes/no»" ?>
xml:lang=""
xml:space="«default / preserve»"
xml:base=""
xml:id=""
<!DOCTYPE documentElementName PUBLIC "-//company nme//specification name and version//EN" "path/to/documenttypedefinition.dtd">
<!ELEMENT elementName «(contents) / "ANY" / "EMPTY"»>
<!ATTLIST elementName attributeName «ID / IDREF / IDREFS / CDATA / NMTOKEN / NMTOKENS / (theDefaultValue) / (value1 | value2 | valueN) » «#IMPLIED / #REQUIRED / #FIXED 'theFixedValue' » >
<!ENTITY entityName "value">
xmlns:xi="http://www.w3.org/2001/XInclude"
<xi:include href="" parse="«xml / text»" xpointer="" encoding="" accept="" accept-language=""> </xi:include>
<xi:fallback> </xi:fallback>
xmlns:xlink="http://www.w3.org/1999/xlink"
xlink:type="«simple / extended / title / locator / resource / arc»"
xlink:href=""
xlink:show="«new / replace / embed / other / none»"
xlink:actuate="«onLoad / onRequest / other / none»"
xlink:title=""
xlink:role=""
xlink:arcrole=""
xlink:label=""
xlink:from=""
xlink:to=""
xlink:type="simple" xlink:href="" xlink:show="«new / replace / embed / other / none»" xlink:actuate="«onLoad / onRequest / other / none)" xlink:title=""
xmlns:ev="http://www.w3.org/2001/xml-events"
<ev:listener id="" event="" observer="«id value»" target="«id value»" handler="«uri»" phase="«default / capture»" propagate="«continue / stop»" defaultAction="«cancel / perform»"/>
ev:event=""
ev:observer="«id value»"
ev:target="«id value»"
ev:handler="«uri»"
ev:phase="«default / capture»"
ev:propagate="«continue / stop»"
ev:defaultAction="«cancel / perform»"
<?xml version="1.0" encoding="UTF-8"?> <frames xmlns="http://www.w3.org/2002/06/xframes/" xml:lang="en"> <head> <title>Framed Page</title> <style type="text/css" media="screen, projection"> #header « height: 10em; » #nav « width: 20%; » #footer « height: 4em; » </style> <style type="text/css" media="print" source="framedprint.css"></style> </head> <group compose="vertical"> <frame xml:id="header" source="header.xhtml" title="Site Logo"/> <group compose="horizontal"> <frame xml:id="nav" source="nav.xhtml" title="Site Navigation Menu"/> <frame xml:id="main" source="home.xhtml" title="Main Content"/> </group> <frame xml:id="footer" source="footer.xhtml" title="Site Footer"/> </group> </frames>
<frame xml:id="" source="" title=""/>
<group compose="«vertical / horizontal / single / free »" «xml:base=""»> </group>
class="wbcs_"
title=""
index.xframes#frames(header=header.xhtml,nav=nav.xhtml,main=content.xhtml,footer=footer.xhtml)
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/namespace" xmlns:x="http://www.example.com/namespace" elementFormDefault="qualified"> <xsd:annotation> <xsd:documentation xml:lang="en"> Example XML Schema </xsd:documentation> </xs:annotation> <!-- If you are to use xml:space, xml:lang, xml:base and/or xml:id in your XML Documents uncomment this xsd:import element: --> <!-- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/03/xml.xsd"> </xsd:import> --> <xsd:element name="example" type="x:exampleType"/> <xsd:complexType name="exampleType"> <xsd:sequence> <xsd:element name="level1" type="x:level1Type" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="id" type="xsd:ID"/> </xsd:complexType> <xsd:complexType name="level1Type"> <xsd:sequence> <xsd:element name="name" type="xsd:normalizedString"/> <xsd:element name="title" type="xsd:normalizedString"/> <xsd:element name="description" type="xsd:string" minOccurs="0"/> <xsd:element name="category" type="xsd:token" minOccurs="0"/> </xsd:sequence> <xsd:attribute name="id" type="xsd:ID"/> </xsd:complexType> </xsd:schema>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.com/namespace path/to/schema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="path/to/schema.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type=""
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:x="http://www.example.com/namespace"> <xsl:output method="html" indent="yes"/> <!-- Extensible Stylesheet Language Transformation for Example Document Transforms To: HTML --> <xsl:template match="//x:doc"> <html> <head> <title>Document (HTML View)</title> </head> <body> <xsl:for-each select="x:page"> <div style="border: 1px solid #ff0000"> <span style="font-style: italic"><xsl:value-of select="x:name"/></span><br/> <span style="font-weight: bold"><xsl:value-of select="x:title"/></span><br/> <xsl:value-of select="x:story"/> </div> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet>

Web-based Code Snippets are copywritten 2008 to Legend Scrolls and Peter Davison.
Web-based Code Snippets are licensed under the Creative Commons Attribution 3.0 Unported.