Meeskond:InsertNameHere: Difference between revisions
From ICO wiki
Jump to navigationJump to search
No edit summary |
|||
Line 4: | Line 4: | ||
===XML=== | ===XML=== | ||
< | <source lang="xml" collapse="true" first-line="2"> | ||
<?xml version="1.0" encoding="utf-8" ?> | <?xml version="1.0" encoding="utf-8" ?> | ||
<?xml-stylesheet type="text/xsl" href="Contacts.xslt"?> | |||
<contacts> | <contacts> | ||
<contact> | |||
<name title="Ms"><![CDATA[Some Name]]></name> | |||
<contactInfo> | |||
<infoType type="phone"> | |||
<data type="mobile"><![CDATA[54321557]]></data> | |||
</infoType> | |||
<infoType type="address"> | |||
<data type="work"><![CDATA[Address 87-2]]></data> | |||
<data type="home"><![CDATA[Highlander 5-987-5.23, Mun]]></data> | |||
</infoType> | |||
<infoType type="email"> | |||
<data type="work"><![CDATA[email1@email.email]]></data> | |||
<data type="home"><![CDATA[email2@email.email]]></data> | |||
</infoType> | |||
</contactInfo> | |||
<notes /> | |||
<groups> | |||
<group group="friend" /> | |||
<group group="family" /> | |||
</groups> | |||
</contact> | |||
<contact> | |||
<name><![CDATA[Other Name]]></name> | |||
<contactInfo> | |||
<infoType type="email"> | |||
<data><![CDATA[some@mail.internet]]></data> | |||
</infoType> | |||
</contactInfo> | |||
<birthday>2000-12-12</birthday> | |||
<notes><![CDATA[these are some notes]]></notes> | |||
<groups> | |||
<group group="work"/> | |||
</groups> | |||
</contact> | |||
</contacts> | </contacts> | ||
</ | </source> | ||
===XSD=== | ===XSD=== | ||
<source lang="xml" collapse="true" first-line="2"> | |||
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<xs:element name="contacts"> | |||
<xs:complexType> | |||
<xs:sequence> | <xs:sequence> | ||
<xs:element maxOccurs="unbounded" name="contact"> | |||
<xs:complexType> | |||
<xs:sequence> | <xs:sequence> | ||
<xs:element name="name"> | |||
<xs:complexType> | |||
<xs:simpleContent> | |||
<xs:extension base="xs:string"> | |||
<xs:attribute name="title" type="xs:string" use="optional" /> | |||
</xs:extension> | |||
</xs:simpleContent> | |||
</xs:complexType> | |||
</xs:element> | |||
<xs:element name="contactInfo"> | |||
<xs:complexType> | |||
<xs:sequence> | |||
<xs:element minOccurs="0" maxOccurs="unbounded" name="infoType"> | |||
<xs:complexType> | |||
<xs:sequence> | |||
<xs:element maxOccurs="unbounded" name="data"> | |||
<xs:complexType> | |||
<xs:simpleContent> | |||
<xs:extension base="xs:string"> | |||
<xs:attribute name="type" type="xs:string" use="optional" /> | |||
</xs:extension> | |||
</xs:simpleContent> | |||
</xs:complexType> | |||
</xs:element> | |||
</xs:sequence> | |||
<xs:attribute name="type" type="xs:string" use="required" /> | |||
</xs:complexType> | |||
</xs:element> | |||
</xs:sequence> | |||
</xs:complexType> | |||
</xs:element> | |||
<xs:element minOccurs="0" name="birthday" type="xs:date"/> | |||
<xs:element name="notes" /> | |||
<xs:element name="groups"> | |||
<xs:complexType> | |||
<xs:sequence> | |||
<xs:element minOccurs="0" maxOccurs="unbounded" name="group"> | |||
<xs:complexType> | |||
<xs:attribute name="group" type="xs:string" use="required" /> | |||
</xs:complexType> | |||
</xs:element> | |||
</xs:sequence> | |||
</xs:complexType> | |||
</xs:element> | |||
</xs:sequence> | </xs:sequence> | ||
</xs:complexType> | |||
</xs:element> | |||
</xs:sequence> | </xs:sequence> | ||
</xs:complexType> | |||
</xs:element> | |||
</xs:schema> | </xs:schema> | ||
</ | </source> | ||
===XSLT=== | |||
<source lang="xml" collapse="true" first-line="2"> | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |||
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"> | |||
<xsl:output method="html" indent="yes" /> | |||
<xsl:template match="/"> | |||
<html> | |||
<title>Contacts</title> | |||
<body> | |||
<h2>Contacts</h2> | |||
<table border="1"> | |||
<!--header row--> | |||
<tr> | |||
<th>Name</th> | |||
<th>Birthday</th> | |||
<th>Phone</th> | |||
<th>Email</th> | |||
<th>Address</th> | |||
<th>Notes</th> | |||
<th>Groups</th> | |||
</tr> | |||
<!--else row--> | |||
<!--for each contact in contacts--> | |||
<xsl:for-each select="contacts/contact"> | |||
<!--row--> | |||
<tr> | |||
<!--name--> | |||
<td> | |||
<xsl:if> | |||
</xsl:if> | |||
<xsl:value-of select="name"/> | |||
</td> | |||
<!--birthday--> | |||
<td> | |||
<xsl:value-of select="birthday"/> | |||
</td> | |||
<!--list of phone numbers--> | |||
<td> | |||
<ul> | |||
<xsl:for-each select="contactInfo/infoType[@type='phone']/data"> | |||
<li> | |||
<xsl:value-of select="."/> | |||
</li> | |||
</xsl:for-each> | |||
</ul> | |||
</td> | |||
<!--list of emails--> | |||
<td> | |||
<ul> | |||
<xsl:for-each select="contactInfo/infoType[@type='email']/data"> | |||
<li> | |||
<xsl:value-of select="." /> | |||
</li> | |||
</xsl:for-each> | |||
</ul> | |||
</td> | |||
<!--list of addresses--> | |||
<td> | |||
<ul> | |||
<xsl:for-each select="contactInfo/infoType[@type='address']/data"> | |||
<li> | |||
<xsl:value-of select="." /> | |||
</li> | |||
</xsl:for-each> | |||
</ul> | |||
</td> | |||
<!--notes--> | |||
<td> | |||
<xsl:value-of select="notes"/> | |||
</td> | |||
<!--groups--> | |||
<td> | |||
<ul> | |||
<xsl:for-each select="groups/group"> | |||
<li> | |||
<xsl:value-of select="@group" /> | |||
</li> | |||
</xsl:for-each> | |||
</ul> | |||
</td> | |||
</tr> | |||
</xsl:for-each> | |||
<!--end of for each for contact in contacts--> | |||
</table> | |||
</body> | |||
</html> | |||
</xsl:template> | |||
</xsl:stylesheet> | |||
</source> |
Revision as of 21:36, 5 March 2015
Meeskond
- Villu Viirsalu
XML
XML
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="Contacts.xslt"?>
<contacts>
<contact>
<name title="Ms"><![CDATA[Some Name]]></name>
<contactInfo>
<infoType type="phone">
<data type="mobile"><![CDATA[54321557]]></data>
</infoType>
<infoType type="address">
<data type="work"><![CDATA[Address 87-2]]></data>
<data type="home"><![CDATA[Highlander 5-987-5.23, Mun]]></data>
</infoType>
<infoType type="email">
<data type="work"><![CDATA[email1@email.email]]></data>
<data type="home"><![CDATA[email2@email.email]]></data>
</infoType>
</contactInfo>
<notes />
<groups>
<group group="friend" />
<group group="family" />
</groups>
</contact>
<contact>
<name><![CDATA[Other Name]]></name>
<contactInfo>
<infoType type="email">
<data><![CDATA[some@mail.internet]]></data>
</infoType>
</contactInfo>
<birthday>2000-12-12</birthday>
<notes><![CDATA[these are some notes]]></notes>
<groups>
<group group="work"/>
</groups>
</contact>
</contacts>
XSD
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="contacts">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="contact">
<xs:complexType>
<xs:sequence>
<xs:element name="name">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="title" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="contactInfo">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="infoType">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="data">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="type" type="xs:string" use="optional" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element minOccurs="0" name="birthday" type="xs:date"/>
<xs:element name="notes" />
<xs:element name="groups">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="group">
<xs:complexType>
<xs:attribute name="group" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes" />
<xsl:template match="/">
<html>
<title>Contacts</title>
<body>
<h2>Contacts</h2>
<table border="1">
<!--header row-->
<tr>
<th>Name</th>
<th>Birthday</th>
<th>Phone</th>
<th>Email</th>
<th>Address</th>
<th>Notes</th>
<th>Groups</th>
</tr>
<!--else row-->
<!--for each contact in contacts-->
<xsl:for-each select="contacts/contact">
<!--row-->
<tr>
<!--name-->
<td>
<xsl:if>
</xsl:if>
<xsl:value-of select="name"/>
</td>
<!--birthday-->
<td>
<xsl:value-of select="birthday"/>
</td>
<!--list of phone numbers-->
<td>
<ul>
<xsl:for-each select="contactInfo/infoType[@type='phone']/data">
<li>
<xsl:value-of select="."/>
</li>
</xsl:for-each>
</ul>
</td>
<!--list of emails-->
<td>
<ul>
<xsl:for-each select="contactInfo/infoType[@type='email']/data">
<li>
<xsl:value-of select="." />
</li>
</xsl:for-each>
</ul>
</td>
<!--list of addresses-->
<td>
<ul>
<xsl:for-each select="contactInfo/infoType[@type='address']/data">
<li>
<xsl:value-of select="." />
</li>
</xsl:for-each>
</ul>
</td>
<!--notes-->
<td>
<xsl:value-of select="notes"/>
</td>
<!--groups-->
<td>
<ul>
<xsl:for-each select="groups/group">
<li>
<xsl:value-of select="@group" />
</li>
</xsl:for-each>
</ul>
</td>
</tr>
</xsl:for-each>
<!--end of for each for contact in contacts-->
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>