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
|
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2024 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<?xml version="1.0" encoding="ISO-8859-1"?>
<refentry id="XP-V-2">
<refmeta>
<refentrytitle>Using XPath queries to XML views</refentrytitle>
<refmiscinfo>tutorial</refmiscinfo>
</refmeta>
<refnamediv>
<refname>Examples</refname>
<refpurpose>Using XPath queries with options.</refpurpose>
</refnamediv>
<refsect1 id="XP-V-2a">
<title>XML serialization text</title>
<para>You can get xml serialization text of the selected entity by the query </para>
<programlisting><![CDATA[
XPATH [__view "xmlview_name"] /xpath_query
]]></programlisting>
<para>e.g. for given 'cat' xml view the full serialization text can be received by the query</para>
<programlisting><![CDATA[
XPATH [__view "cat"] /*
]]></programlisting>
<para>or</para>
<programlisting><![CDATA[
XPATH [__view "cat"] /category
]]></programlisting>
<para>see xp_v_2_sample</para>
</refsect1>
<refsect1 id="XP-V-2b">
<title>Select all columns instead of a serialization text</title>
<para>
You can select all columns of the selected entity instead of its serialization text by using __* option:
</para>
<programlisting><![CDATA[
XPATH [__* __view "cat"] //product
ProductID ProductName SupplierID CategoryID QuantityPerUnit UnitPrice UnitsInStock UnitsOnOrder ReorderLevel Discontinued
INTEGER VARCHAR INTEGER INTEGER VARCHAR DOUBLE PRECISION SMALLINT SMALLINT SMALLINT SMALLINT
______________________________________________________________________________________________________________________
1 Chai 1 1 10 boxes x 20bags 8 39 0 10 0
2 Chang 1 1 24 - 12 oz bottles 19 17 40 25 0
3 Aniseed Syrup 1 2 12 - 550 ml bottles 10 13 70 25 0
. . . . . .
]]></programlisting>
<para>
This is only valid when __view is specified and the result set is homogeneous.
</para>
</refsect1>
<refsect1 id="XP-V-2c">
<title>Select the key instead of the serialization text</title>
<para>
You can select the key of the selected entities instead of the serialization text by using __key option:
</para>
<programlisting><![CDATA[
XPATH [__key __view "cat"] /*;
CategoryID
INTEGER NOT NULL
_______________________________________________________________________________
1
2
3
4
5
6
7
8
]]></programlisting>
</refsect1>
</refentry>
|