-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathexamples.xml
163 lines (154 loc) · 4.3 KB
/
examples.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 10b60deaa2e4353299a66e99eae0f06d53ddb661 Maintainer: nilgun Status: ready -->
<chapter xml:id="xsl.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="xsl.examples-collection">
<title>Örnek collection.xml ve collection.xsl dosyaları</title>
<para>
Bu eklentideki örneklerin çoğu hem bir XML hem de bir XSL dosyası
gerektirir. Örneklerde kullanacağımız <filename>collection.xml</filename> ve
<filename>collection.xsl</filename> dosyalarının içerikleri:
</para>
<para>
<example>
<title>- collection.xml</title>
<programlisting role="xml">
<![CDATA[
<collection>
<cd>
<title>Fight for your mind</title>
<artist>Ben Harper</artist>
<year>1995</year>
</cd>
<cd>
<title>Electric Ladyland</title>
<artist>Jimi Hendrix</artist>
<year>1997</year>
</cd>
</collection>
]]>
</programlisting>
</example>
<example>
<title>- collection.xsl</title>
<programlisting role="xml">
<![CDATA[
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="owner" select="'Nicolas Eliaszewicz'"/>
<xsl:output method="html" encoding="utf-8" indent="no"/>
<xsl:template match="collection">
Hey! Welcome to <xsl:value-of select="$owner"/>'s sweet CD collection!
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="cd">
<h1><xsl:value-of select="title"/></h1>
<h2>by <xsl:value-of select="artist"/> - <xsl:value-of select="year"/></h2>
<hr />
</xsl:template>
</xsl:stylesheet>
]]>
</programlisting>
</example>
</para>
</section>
<section xml:id="xsl.examples-errors">
<title>libxml hata işleme işlevleri ile hataların işlenmesi</title>
<para>
libxml, hataları işlemek için XSLT işlemedeki hataları yakalamak ve bunlarla
başa çıkmak için kullanılabilecek bir dizi işlev sunar.
</para>
<para>
<example>
<title>fruits.xml</title>
<para>Geçerli bir XML dosyası.</para>
<programlisting role="xml">
<![CDATA[
<fruits>
<fruit>Apple</fruit>
<fruit>Banana</fruit>
<fruit>Cherry</fruit>
</fruits>
]]>
</programlisting>
</example>
<example>
<title>fruits.xsl</title>
<para>Geçersiz bir seçim ifadesi içeriyor.</para>
<programlisting role="xml">
<![CDATA[
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" indent="no"/>
<xsl:template match="fruits">
<ul>
<xsl:apply-templates/>
</ul>
</xsl:template>
<xsl:template match="fruit">
<li><xsl:value-of select="BU KASITLI BİR HATADIR!"/></li>
</xsl:template>
</xsl:stylesheet>
]]>
</programlisting>
</example>
<example xml:id="xsl.examples-errors.capture">
<title>Hataları karşılaştırma ve çıktılama</title>
<para>
Aşağıdaki örnek,
<methodname>XSLTProcessor::importStyleSheet</methodname> hata içeren
bir XSLT betiğiyle çağrılırken ortaya çıkan libxml hatalarını yakalar
ve görüntüler.
</para>
<programlisting role="php">
<![CDATA[
<?php
$xmldoc = new DOMDocument();
$xsldoc = new DOMDocument();
$xsl = new XSLTProcessor();
$xmldoc->loadXML('fruits.xml');
$xsldoc->loadXML('fruits.xsl');
libxml_use_internal_errors(true);
$result = $xsl->importStyleSheet($xsldoc);
if (!$result) {
foreach (libxml_get_errors() as $error) {
echo "Libxml error: {$error->message}\n";
}
}
libxml_use_internal_errors(false);
if ($result) {
echo $xsl->transformToXML($xmldoc);
}
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
Libxml error: Invalid expression
Libxml error: compilation error: file fruits.xsl line 9 element value-of
Libxml error: xsl:value-of : could not compile select expression 'BU KASITLI BİR HATADIR!'
]]>
</screen>
</example>
</para>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->