<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/Simple" xmlns:tns="http://www.example.org/Simple"
elementFormDefault="qualified">
<xs:complexType name="user" mixed="true">
<xs:sequence>
<xs:element name="name" type="xs:string" default="Eric001" />
<xs:element name="age" type="tns:age" default="30" />
<xs:element name="gender" type="tns:gender" default="Male" />
<xs:element name="password" type="tns:password" />
<xs:any maxOccurs="unbounded"></xs:any>
</xs:sequence>
<xs:attribute name="role" type="xs:string"/>
</xs:complexType>
<xs:simpleType name="gender">
<xs:restriction base="xs:string">
<xs:enumeration value="Male" />
<xs:enumeration value="Female" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="age">
<xs:restriction base="xs:integer">
<xs:minInclusive value="1" />
<xs:maxInclusive value="120" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="letter">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Za-z0-9]"></xs:pattern>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="password">
<xs:restriction base="xs:string">
<xs:pattern value="(([0-9]+[a-zA-Z]+)|([a-zA-Z]+[0-9]+))"></xs:pattern>
<xs:minLength value="5" />
<xs:maxLength value="8" />
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="amount">
<xs:restriction base="xs:decimal">
<xs:totalDigits value="2"></xs:totalDigits>
</xs:restriction>
</xs:simpleType>
<xs:element name="root">
<xs:complexType mixed="true">
<xs:sequence>
<xs:any maxOccurs="unbounded"></xs:any>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="user" type="tns:user" >
</xs:element>
<xs:element name="cost" type="tns:amount" />
<xs:element name="title"></xs:element>
</xs:schema>
Following is the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<tns:root xmlns:tns="http://www.example.org/Simple" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/Simple Simple.xsd ">
This is an user test
<tns:user role="admin">
<tns:name>tnsname1</tns:name>
<tns:age>18</tns:age>
<tns:gender>Male</tns:gender>
<tns:password>sfds3555</tns:password>
<tns:title/>
</tns:user>
<tns:user role="admin">
<tns:name>tnsname1</tns:name>
<tns:age>18</tns:age>
<tns:gender>Male</tns:gender>
<tns:password>sfds3555</tns:password>
<tns:title/>
</tns:user>
<tns:cost>0.22</tns:cost>
<tns:cost>0</tns:cost>
</tns:root>
Showing posts with label docbook. Show all posts
Showing posts with label docbook. Show all posts
Friday, September 19, 2008
Wednesday, September 17, 2008
Add bookmark on docbook PDF
In this article I'll discuss two points about docbook that generate to PDF.I use the ant to generate docbook,following is my ant file.
<!--
- target: build-pdf
- description: Iterates through a directory and transforms
- .xml files into .fo files which can then be turned into DocBook XML
- files.
-->
<target name="build-pdf" depends="depends"
description="Generates PDF files from DocBook XML">
<xslt style="${fo.stylesheet}" extension=".fo"
basedir="${basedir}/src" destdir="${target.dir}/fo">
<classpath refid="xalan.classpath" />
<include name="**/*.xml" />
<exclude name="**/*chapter*.xml"/>
</xslt>
<property name="fop.home" value="${basedir}/lib/fop-0.95"/>
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
<classpath>
<fileset dir="${fop.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${fop.home}/build">
<include name="fop.jar" />
</fileset>
</classpath>
</taskdef>
<fop format="application/pdf"
outdir="${target.dir}/pdf" basedir="${target.dir}/fo">
<fileset dir="${target.dir}/fo">
<include name="*.fo"/>
</fileset>
</fop>
</target>
following is my dobook segment:
<sect1>
<title>Section 1 title</title>
<para>
<sect2>
<title>section 2 title</title>
<para>
description...
</para>
<sect3>
<para>witing something...</para>
<sect3>
</sect2>
</sect1>
Now the question is;
1)I want to display the label of section.
2)I want to display the bookmark in PDF.
The final solution is change the param.xml file.
1)to display the label of section:
change following line
<xsl:param name="section.autolabel" select="0">
to this line
<xsl:param name="section.autolabel" select="1">
2)to display the bookmark in PDF.
change following line
<xsl:param name="fop1.extensions" select="0">
to this line
<xsl:param name="fop1.extensions" select="1">
Note:don't change following line otherwise you will get an exception like:
No element mapping definition found for (Namespace URI: "http://xml.apache.org/fop/extensions", Local Name: "destination")
<xsl:param name="fop.extensions" select="0">
<!--
- target: build-pdf
- description: Iterates through a directory and transforms
- .xml files into .fo files which can then be turned into DocBook XML
- files.
-->
<target name="build-pdf" depends="depends"
description="Generates PDF files from DocBook XML">
<xslt style="${fo.stylesheet}" extension=".fo"
basedir="${basedir}/src" destdir="${target.dir}/fo">
<classpath refid="xalan.classpath" />
<include name="**/*.xml" />
<exclude name="**/*chapter*.xml"/>
</xslt>
<property name="fop.home" value="${basedir}/lib/fop-0.95"/>
<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
<classpath>
<fileset dir="${fop.home}/lib">
<include name="*.jar"/>
</fileset>
<fileset dir="${fop.home}/build">
<include name="fop.jar" />
</fileset>
</classpath>
</taskdef>
<fop format="application/pdf"
outdir="${target.dir}/pdf" basedir="${target.dir}/fo">
<fileset dir="${target.dir}/fo">
<include name="*.fo"/>
</fileset>
</fop>
</target>
following is my dobook segment:
<sect1>
<title>Section 1 title</title>
<para>
<sect2>
<title>section 2 title</title>
<para>
description...
</para>
<sect3>
<para>witing something...</para>
<sect3>
</sect2>
</sect1>
Now the question is;
1)I want to display the label of section.
2)I want to display the bookmark in PDF.
The final solution is change the param.xml file.
1)to display the label of section:
change following line
<xsl:param name="section.autolabel" select="0">
to this line
<xsl:param name="section.autolabel" select="1">
2)to display the bookmark in PDF.
change following line
<xsl:param name="fop1.extensions" select="0">
to this line
<xsl:param name="fop1.extensions" select="1">
Note:don't change following line otherwise you will get an exception like:
No element mapping definition found for (Namespace URI: "http://xml.apache.org/fop/extensions", Local Name: "destination")
<xsl:param name="fop.extensions" select="0">
Labels:
docbook
Subscribe to:
Posts (Atom)