Skip to content

Instantly share code, notes, and snippets.

@nkcr
Last active May 11, 2016 12:53
Show Gist options
  • Save nkcr/fc6a9e794355ee6cb5587d0ad5b0576f to your computer and use it in GitHub Desktop.
Save nkcr/fc6a9e794355ee6cb5587d0ad5b0576f to your computer and use it in GitHub Desktop.
contact.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Main instance -->
<xs:element name="contact">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<!-- Title, firstname, lastname -->
<xs:element name="title" type="titleType"/>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
<!-- The adress -->
<xs:element name="address">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<!-- Street, number, city, NPA -->
<xs:element name="street" type="xs:string"/>
<xs:element name="number" type="xs:positiveInteger"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="npa" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<!-- The title type, either "Mr." or "Mme." -->
<xs:simpleType name="titleType">
<xs:restriction base="xs:string">
<xs:enumeration value="Mr."/>
<xs:enumeration value="Mme."/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
<fo:region-body margin="1in" margin-top="1in" margin-bottom="1.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body" font-family="arial">
<fo:block text-align="center" padding="0 0 30px 0" font-size="18px">
<xsl:text>Liste des étudiants</xsl:text>
</fo:block>
<xsl:for-each select="students/student">
<fo:block-container height="3cm" width="8cm" border="1px solid" padding="10px" margin="7px">
<fo:block text-align="end" line-height="18pt" font-family="sans-serif">
<xsl:value-of select="contact/title" /> <xsl:text> </xsl:text> <xsl:value-of select="contact/firstname" /> <xsl:text> </xsl:text> <xsl:value-of select="contact/lastname" />
</fo:block>
<fo:block text-align="end" line-height="18pt" font-family="sans-serif">
<xsl:value-of select="contact/address/street" /> <xsl:text> </xsl:text> <xsl:value-of select="contact/address/number" />
</fo:block>
<fo:block text-align="end" line-height="18pt" font-family="sans-serif">
<xsl:value-of select="contact/address/npa" /> <xsl:text> </xsl:text> <xsl:value-of select="contact/address/city" />
</fo:block>
</fo:block-container>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Main instance -->
<xs:element name="sessions">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<!-- A session -->
<xs:element name="session" maxOccurs="unbounded">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<!-- Informations, start date, end date -->
<xs:element name="information" type="xs:string"/>
<xs:element name="date" type="xs:date"/>
<xs:element name="sTime" type="xs:time"/>
<xs:element name="eTime" type="xs:time"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment