diff --git a/Doc/Common/snippets.xml b/Doc/Common/snippets.xml index d1691c16919e00760a6a9100fb3009cbc022ea00..26b7ce1a00114eadd5fc63f3e6095e02b504396d 100644 --- a/Doc/Common/snippets.xml +++ b/Doc/Common/snippets.xml @@ -28,11 +28,10 @@ <title/> <programlisting language="none">http://www.utf8-chartable.de/unicode-utf8-table.pl?start=9472&unicodeinhtml=dec -<emphasis role="red"> + <emphasis role="red">â–²</emphasis> -◀─┼─▶</emphasis> +<emphasis role="red">◀─┼─▶</emphasis> <emphasis role="red">â–¼</emphasis> - <emphasis role="red">┌──â”</emphasis> <emphasis role="red">│</emphasis> <emphasis role="red">│</emphasis> <emphasis role="red">â””</emphasis> <emphasis role="red">┘</emphasis> diff --git a/Doc/Sda1/Ref/Memo/V70_final/Test/duplicateContactId.xml b/Doc/Sda1/Ref/Memo/V70_final/Test/duplicateContactId.xml new file mode 100644 index 0000000000000000000000000000000000000000..2967b0b3d7ae708fad6e172e0dc2c90156adb4bf --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/Test/duplicateContactId.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<memo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../memo.xsd" + date="2014-09-24" priority="medium"> + <contacts> + <entry id="10"> + <commonName>Susan Sonntag</commonName> + <tel>+44332232323</tel> + <email>susan23@evermail.com</email> + <email>susa112@private.uk</email> + </entry> + <entry id="20"> + <commonName>John Balber</commonName> + <email>balber@hatebook.com</email> + <tel>017297123232</tel> + <email>home@balber.org</email> + </entry> + <entry id="20"> <!-- Invalid: duplicate contact @id value --> + <commonName>Mary Palmer</commonName> + <tel>017297123232</tel> + </entry> + </contacts> + + <from contact="10"/> + <to contact="20"/> + <subject>Best whishes</subject> + <content> + <para>Have a nice trip!</para> + <para>I feel <emphasis>very</emphasis> happy for you. Don't miss <link href="https://www.wikipedia.org">sharing your results</link>.</para> + </content> +</memo> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Memo/V70_final/Test/duplicateRecipient.xml b/Doc/Sda1/Ref/Memo/V70_final/Test/duplicateRecipient.xml new file mode 100644 index 0000000000000000000000000000000000000000..e883dfcd568e39892c644490d2648c4130dd9533 --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/Test/duplicateRecipient.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<memo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../memo.xsd" + date="2014-09-24" priority="medium"> + <contacts> + <entry id="10"> + <commonName>Susan Sonntag</commonName> + <tel>+44332232323</tel> + <email>susan23@evermail.com</email> + <email>susa112@private.uk</email> + </entry> + <entry id="20"> + <commonName>John Balber</commonName> + <email>balber@hatebook.com</email> + <tel>017297123232</tel> + <email>home@balber.org</email> + </entry> + <entry id="25"> + <commonName>Mary Palmer</commonName> + <tel>017297123232</tel> + </entry> + </contacts> + + <from contact="100"/> <!-- invalid: no such sender id --> + <to contact="20"/> + <to contact="25"/> + <subject>Best whishes</subject> + <content> + <para>Have a nice trip!</para> + <para>I feel <emphasis>very</emphasis> happy for you. Don't miss <link href="https://www.wikipedia.org">sharing your results</link>.</para> + </content> +</memo> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Memo/V70_final/Test/email.xml b/Doc/Sda1/Ref/Memo/V70_final/Test/email.xml new file mode 100644 index 0000000000000000000000000000000000000000..725ad1acdbd3ef9cdb4b0a3a73aaa3e1a431da08 --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/Test/email.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<contacts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../memo.xsd"> + + <entry id="10"> + <commonName>Susan Sonntag</commonName> + <tel>+44332232323</tel> + <email>susan23@evermail.com</email><!-- valid --> + <email>susan23</email><!-- invalid: No »@« sign --> + <email>susan23@.evermail.com</email><!-- invalid: No ».« immediately after »@« sign --> + <email>susan23@evermail@com</email><!-- invalid: no second »@« --> + </entry> + +</contacts> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Memo/V70_final/Test/missingAddress.xml b/Doc/Sda1/Ref/Memo/V70_final/Test/missingAddress.xml new file mode 100644 index 0000000000000000000000000000000000000000..e44a96fe5622dd50e533ec869d52ee97a414f940 --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/Test/missingAddress.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<contacts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../memo.xsd"> + + <entry id="10"> + <commonName>Susan Sonntag</commonName> + <!-- invalid: neither email nor phone provided. --> + </entry> + +</contacts> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Memo/V70_final/Test/noSuchSender.xml b/Doc/Sda1/Ref/Memo/V70_final/Test/noSuchSender.xml new file mode 100644 index 0000000000000000000000000000000000000000..f02ea3e48eab90b65a5d64e499a98e931cb6488e --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/Test/noSuchSender.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<memo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../memo.xsd" + date="2014-09-24" priority="medium"> + <contacts> + <entry id="10"> + <commonName>Susan Sonntag</commonName> + <tel>+44332232323</tel> + <email>susan23@evermail.com</email> + <email>susa112@private.uk</email> + </entry> + <entry id="20"> + <commonName>John Balber</commonName> + <email>balber@hatebook.com</email> + <tel>017297123232</tel> + <email>home@balber.org</email> + </entry> + <entry id="25"> + <commonName>Mary Palmer</commonName> + <tel>017297123232</tel> + </entry> + </contacts> + + <from contact="10"/> + <to contact="20"/> + <to contact="20"/> <!-- invalid: duplicate recipient --> + <subject>Best whishes</subject> + <content> + <para>Have a nice trip!</para> + <para>I feel <emphasis>very</emphasis> happy for you. Don't miss <link href="https://www.wikipedia.org">sharing your results</link>.</para> + </content> +</memo> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Memo/V70_final/Test/tel.xml b/Doc/Sda1/Ref/Memo/V70_final/Test/tel.xml new file mode 100644 index 0000000000000000000000000000000000000000..404e0929a12bf3d7d3087e766a45820509f848af --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/Test/tel.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<contacts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="../memo.xsd"> + + <entry id="10"> + <commonName>Susan Sonntag</commonName> + <tel>+44332232323</tel> <!-- Valid --> + <tel>+044332232323</tel> <!-- Invalid: No »0« immediately after »+« --> + <tel>+44 332232323</tel> <!-- Invalid: No spaces--> + <tel>+4</tel> <!-- Invalid: One missing digit--> + </entry> + +</contacts> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Memo/V70_final/memo.xsd b/Doc/Sda1/Ref/Memo/V70_final/memo.xsd new file mode 100644 index 0000000000000000000000000000000000000000..916a23e05ed4106854fd54a6bc19f89a9bf67eff --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/memo.xsd @@ -0,0 +1,120 @@ +<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" + xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" elementFormDefault="qualified" + vc:minVersion="1.0" vc:maxVersion="1.1"> + +<!-- Data types --> + <xs:simpleType name="Priority"> + <xs:annotation> + <xs:documentation>A memo may have different priorities</xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:enumeration value="low"/> + <xs:enumeration value="medium"/> + <xs:enumeration value="high"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="emailType"> + <xs:restriction base="xs:string"> + <xs:pattern value="[_\-a-zA-Z0-9\.\+]+@[a-zA-Z0-9](\.?[\-a-zA-Z0-9]*[a-zA-Z0-9])*"/> + </xs:restriction> + </xs:simpleType> + + <xs:simpleType name="telType"> + <xs:restriction base="xs:string"> + <xs:pattern value="([+][1-9][0-9])?[0-9]+"/> + </xs:restriction> + </xs:simpleType> + +<!-- Elements --> + <xs:element name="entry"> + <xs:complexType> + <xs:sequence> + <xs:element type="xs:string" name="commonName"/> + <xs:choice maxOccurs="unbounded"> + <xs:element name="email" type="emailType"/> + <xs:element name="tel" type="telType"/> + </xs:choice> + </xs:sequence> + <xs:attribute name="id" type="xs:int" use="required"/> + </xs:complexType> + </xs:element> + + <xs:element name="contacts"> + <xs:complexType> + <xs:sequence> + <xs:element ref="entry" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + + <xs:element name="from"> + <xs:complexType> + <xs:attribute name="contact" type="xs:int" use="required"/> + </xs:complexType> + </xs:element> + + <xs:element name="to"> + <xs:complexType> + <xs:attribute name="contact" type="xs:int" use="required"/> + </xs:complexType> + </xs:element> + + <xs:element name="link" > + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> + <xs:attribute name="href" type="xs:anyURI"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> + </xs:element> + + <xs:element name="para"> + <xs:complexType mixed="true"> + <xs:sequence minOccurs="0" maxOccurs="unbounded"> + <xs:choice> + <xs:element name="emphasis" type="xs:string" /> + <xs:element ref="link"/> + </xs:choice> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="content"> + <xs:complexType> + <xs:sequence> + <xs:element ref="para" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + </xs:element> + + <xs:element name="memo"> + <xs:complexType> + <xs:sequence> + <xs:element ref="contacts"/> + <xs:element ref="from" /> + <xs:element ref="to" minOccurs="1" maxOccurs="unbounded"/> + <xs:element name="subject" type="xs:string"/> + <xs:element ref="content"/> + </xs:sequence> + <xs:attribute name="date" type="xs:date" use="required"/> + <xs:attribute name="priority" type="Priority" use="optional"/> + </xs:complexType> + <xs:key name="uniqueContactId"> + <xs:selector xpath="contacts/entry"/> + <xs:field xpath="@id"/> + </xs:key> + <xs:key name="uniqueRecipientId"> + <xs:selector xpath="to"/> + <xs:field xpath="@contact"/> + </xs:key> + + <xs:keyref refer="uniqueContactId" name="contactReference"> + <xs:selector xpath="from|to"/> + <xs:field xpath="@contact"></xs:field> + </xs:keyref> + </xs:element> + +</xs:schema> diff --git a/Doc/Sda1/Ref/Memo/V70_final/message.xml b/Doc/Sda1/Ref/Memo/V70_final/message.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a4c7d1292f9f0bd0f28a6134b568acbf99aa24f --- /dev/null +++ b/Doc/Sda1/Ref/Memo/V70_final/message.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<memo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="memo.xsd" + date="2014-09-24" priority="medium"> + <contacts> + <entry id="10"> + <commonName>Susan Sonntag</commonName> + <tel>+44332232323</tel> + <email>susan23@evermail.com</email> + <email>susa112@private.uk</email> + </entry> + <entry id="20"> + <commonName>John Balber</commonName> + <email>balber@hatebook.com</email> + <tel>017297123232</tel> + <email>home@balber.org</email> + </entry> + <entry id="25"> + <commonName>Mary Palmer</commonName> + <tel>017297123232</tel> + </entry> + </contacts> + + <from contact="10"/> + <to contact="20"/> + <to contact="25"/> + <subject>Best whishes</subject> + <content> + <para>Have a nice trip!</para> + <para>I feel <emphasis>very</emphasis> happy for you. Don't miss <link href="https://www.wikipedia.org">sharing your results</link>.</para> + </content> +</memo> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Xmlschema/P/MemoSqlModel/schema.sql b/Doc/Sda1/Ref/Memo/schema.sql similarity index 100% rename from Doc/Sda1/Ref/Xmlschema/P/MemoSqlModel/schema.sql rename to Doc/Sda1/Ref/Memo/schema.sql diff --git a/Doc/Sda1/Ref/Memo/src/main/java/de/hdm_stuttgart/mi/sda1/App.java b/Doc/Sda1/Ref/Memo/src/main/java/de/hdm_stuttgart/mi/sda1/App.java new file mode 100644 index 0000000000000000000000000000000000000000..127c25b4b38fca2392b9456dbce811fb34ff562a --- /dev/null +++ b/Doc/Sda1/Ref/Memo/src/main/java/de/hdm_stuttgart/mi/sda1/App.java @@ -0,0 +1,29 @@ +package de.hdm_stuttgart.mi.sda1; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +/** + * A simple http://logging.apache.org/log4j/2.x demo, + * see file resources/log4j2.xml for configuration options + * and A1.log containing debugging output. + */ + +public class App { + private static Logger log = LogManager.getLogger(App.class); + + /** + * Your application's main entry point. + * + * @param args Yet unused + */ + public static void main( String[] args ) { + System.out.println( "Hello World!" ); + + log.debug("With respect to logging you may want to configure file "); + log.debug("'src/main/resources/log4j2.xml' to suit your needs."); + log.debug("This config file 'log4j2.xml' will result in 'A1.log'"); + log.debug("file containing logging output as well."); + } +} diff --git a/Doc/Sda1/Ref/Memo/src/main/resources/log4j2.xml b/Doc/Sda1/Ref/Memo/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..eb20b442affff60c0ad812f843ef54a2a0a9c37f --- /dev/null +++ b/Doc/Sda1/Ref/Memo/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <!-- You my want to define class or package level per-logger rules --> + <Logger name="de.hdm_stuttgart.mi.sda1.App" level="debug"> + <AppenderRef ref="A1"/> + </Logger> + <Root level="info"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Memo/src/test/java/de/hdm_stuttgart/mi/sda1/AppTest.java b/Doc/Sda1/Ref/Memo/src/test/java/de/hdm_stuttgart/mi/sda1/AppTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7c4b69e38e51c0f55a2e5203edc2da83368bac82 --- /dev/null +++ b/Doc/Sda1/Ref/Memo/src/test/java/de/hdm_stuttgart/mi/sda1/AppTest.java @@ -0,0 +1,17 @@ +package de.hdm_stuttgart.mi.sda1; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest { + /** + * Dummy test method + */ + @Test + public void testApp() { + Assert.assertTrue( true ); + } +} diff --git a/Doc/Sda1/Ref/Organizer/src/main/java/de/hdm_stuttgart/mi/sda1/App.java b/Doc/Sda1/Ref/Organizer/src/main/java/de/hdm_stuttgart/mi/sda1/App.java new file mode 100644 index 0000000000000000000000000000000000000000..127c25b4b38fca2392b9456dbce811fb34ff562a --- /dev/null +++ b/Doc/Sda1/Ref/Organizer/src/main/java/de/hdm_stuttgart/mi/sda1/App.java @@ -0,0 +1,29 @@ +package de.hdm_stuttgart.mi.sda1; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +/** + * A simple http://logging.apache.org/log4j/2.x demo, + * see file resources/log4j2.xml for configuration options + * and A1.log containing debugging output. + */ + +public class App { + private static Logger log = LogManager.getLogger(App.class); + + /** + * Your application's main entry point. + * + * @param args Yet unused + */ + public static void main( String[] args ) { + System.out.println( "Hello World!" ); + + log.debug("With respect to logging you may want to configure file "); + log.debug("'src/main/resources/log4j2.xml' to suit your needs."); + log.debug("This config file 'log4j2.xml' will result in 'A1.log'"); + log.debug("file containing logging output as well."); + } +} diff --git a/Doc/Sda1/Ref/Organizer/src/main/resources/log4j2.xml b/Doc/Sda1/Ref/Organizer/src/main/resources/log4j2.xml new file mode 100644 index 0000000000000000000000000000000000000000..eb20b442affff60c0ad812f843ef54a2a0a9c37f --- /dev/null +++ b/Doc/Sda1/Ref/Organizer/src/main/resources/log4j2.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Configuration> + <Appenders> + <File name="A1" fileName="A1.log" append="false"> + <PatternLayout pattern="%t %-5p %c{2} - %m%n"/> + </File> + <Console name="STDOUT" target="SYSTEM_OUT"> + <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> + </Console> + </Appenders> + <Loggers> + + <!-- You my want to define class or package level per-logger rules --> + <Logger name="de.hdm_stuttgart.mi.sda1.App" level="debug"> + <AppenderRef ref="A1"/> + </Logger> + <Root level="info"> + <AppenderRef ref="STDOUT"/> + </Root> + </Loggers> +</Configuration> \ No newline at end of file diff --git a/Doc/Sda1/Ref/Organizer/src/test/java/de/hdm_stuttgart/mi/sda1/AppTest.java b/Doc/Sda1/Ref/Organizer/src/test/java/de/hdm_stuttgart/mi/sda1/AppTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7c4b69e38e51c0f55a2e5203edc2da83368bac82 --- /dev/null +++ b/Doc/Sda1/Ref/Organizer/src/test/java/de/hdm_stuttgart/mi/sda1/AppTest.java @@ -0,0 +1,17 @@ +package de.hdm_stuttgart.mi.sda1; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Unit test for simple App. + */ +public class AppTest { + /** + * Dummy test method + */ + @Test + public void testApp() { + Assert.assertTrue( true ); + } +} diff --git a/Doc/Sda1/xmlschema.xml b/Doc/Sda1/xmlschema.xml index 83f16339ebfaccf18ddd0b7293805879bce950df..7e26b99bb55d5df42888a058320a327ac0f1c3cd 100644 --- a/Doc/Sda1/xmlschema.xml +++ b/Doc/Sda1/xmlschema.xml @@ -1269,6 +1269,785 @@ String s1 = new String(), s2 = new String();</programlisting> </tr> </informaltable> </figure> + + <figure xml:id="sda1_xmlschema_fig_textContentAttribute"> + <title>Ooops: Text content and attributes</title> + + <informaltable border="0"> + <tr> + <td valign="top"><programlisting language="none"><a href="https://my.com">Some text</a> + <emphasis role="red">â–²</emphasis> + <emphasis role="red">│</emphasis> + <emphasis role="red">│</emphasis> + <!-- Just a string --></programlisting></td> + + <td valign="top"><programlisting language="none"><xs:element name="a"> + <xs:complexType> + <xs:simpleContent> + <xs:extension base="xs:string"> <co + linkends="sda1_xmlschema_fig_textContentAttribute-1" + xml:id="sda1_xmlschema_fig_textContentAttribute-1-co"/> + <xs:attribute name="href" type="xs:anyURI"/> <co + linkends="sda1_xmlschema_fig_textContentAttribute-2" + xml:id="sda1_xmlschema_fig_textContentAttribute-2-co"/> + </xs:extension> + </xs:simpleContent> + </xs:complexType> +</xs:element></programlisting></td> + </tr> + </informaltable> + </figure> + + <calloutlist> + <callout arearefs="sda1_xmlschema_fig_textContentAttribute-1-co" + xml:id="sda1_xmlschema_fig_textContentAttribute-1"> + <para>The <tag class="starttag">a</tag> element will contain pure + text.</para> + </callout> + + <callout arearefs="sda1_xmlschema_fig_textContentAttribute-2-co" + xml:id="sda1_xmlschema_fig_textContentAttribute-2"> + <para>The element will have an <xref linkend="glo_URL"/> + representing attribute <tag class="starttag">a + href="..."</tag>.</para> + </callout> + </calloutlist> + </section> + + <section xml:id="xpath"> + <title><link xlink:href="https://www.w3.org/TR/xpath">XPath</link> and + node sets</title> + + <para><xref linkend="glo_SQL"/> allows for predicate base queries + returning a set of data records:</para> + + <figure xml:id="sda1_fig_sqlQueryPrinciple"> + <title><xref linkend="glo_SQL"/> query result</title> + + <informaltable border="0"> + <tr> + <th>Query</th> + + <th>Set</th> + </tr> + + <tr> + <td valign="top"><programlisting language="sql">SELECT name, email +from Customer +WHERE dept='finance' + or category = 12</programlisting></td> + + <td valign="top"><screen>{ + ('John Yates', 'yates@company.com'), + ('Sandra Barnes', 'barnes@testcenter.org'), +... +}</screen></td> + </tr> + </informaltable> + </figure> + + <para>Likewise the <acronym + xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> standard allows + for predicate based queries on XML documents retrieving node sets. Thus + its role may be compared to <xref linkend="glo_SQL"/> + <code>SELECT</code> ... <code>FROM</code> ...<code>WHERE</code> queries. + Some simple examples:</para> + + <figure xml:id="sda1_fig_sqlXpathCompare"> + <title>Comparing <xref linkend="glo_SQL"/> and <xref + linkend="glo_XPath"/></title> + + <para>Predicate based queries:</para> + + <informaltable border="1"> + <tr> + <td valign="top"><programlisting language="sql">SELECT name, email +from Customer +WHERE dept='finance' + or category = 12</programlisting></td> + + <td valign="top"><programlisting language="xml"><database> + ... + <customer dept='finance'>... + +</database></programlisting><programlisting language="xslt">/database//customer[@dept='finance' + or category='7']</programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="sda1_fig_sqlXpathCommonDifferent"> + <title>Similarities and differences</title> + + <para>Predicate base queries:</para> + + <informaltable border="1"> + <tr> + <th><xref linkend="glo_SQL"/></th> + + <th><xref linkend="glo_XPath"/></th> + </tr> + + <tr> + <td align="center" colspan="2" valign="top"><itemizedlist> + <listitem> + <para>Predicate based queries using boolean algebra</para> + </listitem> + </itemizedlist></td> + </tr> + + <tr> + <td valign="top"><itemizedlist> + <listitem> + <para>Joins</para> + </listitem> + + <listitem> + <para><quote>Flat</quote> data</para> + </listitem> + </itemizedlist></td> + + <td valign="top"><itemizedlist> + <listitem> + <para>Hierarchical data support</para> + </listitem> + + <listitem> + <para>Polymorphic results</para> + </listitem> + </itemizedlist></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathExamples"> + <title>Simple <acronym + xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> + queries</title> + + <mediaobject> + <imageobject> + <imagedata fileref="Ref/Fig/xpath.fig" scale="65"/> + </imageobject> + </mediaobject> + </figure> + + <figure xml:id="sda1_fig_xpathFileSystemAnalogyRelative"> + <title>Relative file system search using <command + xlink:href="https://shapeshed.com/unix-find">find</command></title> + + <para>Starting from relative directory context:</para> + + <programlisting language="bash">find . -type d -name Gyre-P\*</programlisting> + + <para>Result:</para> + + <screen>./HTML-CSS/fonts/Gyre-Pagella +./SVG/fonts/Gyre-Pagella</screen> + </figure> + + <figure xml:id="sda1_fig_xpathFileSystemAnalogyAbsolute"> + <title><command + xlink:href="https://shapeshed.com/unix-find">find</command> starting + from absolute path</title> + + <para>Starting from absolute directory context:</para> + + <programlisting language="bash">find /etc/ -type f -and -name pac\*</programlisting> + + <para>Result:</para> + + <screen>/etc/brltty/Input/fs/pacmate.ktb +/etc/gnome-app-install/packages-whitelist</screen> + </figure> + + <figure xml:id="fig_XpathContextNodeEx1"> + <title><xref linkend="glo_XPath"/> and context nodes</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para><tag class="starttag">top</tag></para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>b/a</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b id="first"> + <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Four<emphasis role="red"></a></emphasis> + </b> + <c>Mixed<a>content></a>Example</c> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathContextNodeEx2"> + <title>Union</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para><tag class="starttag">top</tag></para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>(b|c)</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <emphasis role="red"><b id="first"></emphasis> + <a>One</a> + <a>Two</a> + <a>Three</a> + <a>Four</a> + <emphasis role="red"></b></emphasis> + <emphasis role="red"><c></emphasis>Mixed<a>content></a>Example<emphasis + role="red"></c></emphasis> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathContextNodeUnionDescent"> + <title>Union / descent</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para><tag class="starttag">top</tag></para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>(b|c)/a</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b> + <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Four<emphasis role="red"></a></emphasis> + </b> + <c>Mixed <emphasis role="red"><a></emphasis>content<emphasis + role="red"></a> </emphasis>Example</c> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathContextNodeEx3"> + <title>Recursive search for element name</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//a</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b> + <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Four<emphasis role="red"></a></emphasis> + </b> + <c>Mixed <emphasis role="red"><a></emphasis>content<emphasis + role="red"></a> </emphasis>Example</c> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathContextNodeRecursivePlusIndex"> + <title>Recursive + index search</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//a[2]</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b> + <a>One</a> + <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> + <a>Three</a> + <a>Four</a> + </b> + <c>Mixed<a>content></a>Example</c> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathContextNodeSurprise"> + <title>Surprise!</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//a[1]</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b> + <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> + <a>Two</a> + <a>Three</a> + <a>Four</a> + </b> + <c>Mixed<emphasis role="red"><a></emphasis>content><emphasis + role="red"></a></emphasis>Example</c> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="sda1_fig_siblings"> + <title>Siblings</title> + + <glosslist> + <glossentry> + <glossterm><code>preceeding-siblings::*</code></glossterm> + + <glossdef> + <para>All nodes having the same parent node as the content node + and appearing <quote>before</quote> the context node.</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm><code>following-siblings::*</code></glossterm> + + <glossdef> + <para>All nodes having the same parent node as the content node + and appearing <quote>after</quote> the context node.</para> + </glossdef> + </glossentry> + </glosslist> + + <para><quote>Before</quote> and <quote>after</quote> with respect to + <link + xlink:href="https://en.wikipedia.org/wiki/Depth-first_search">depth-first</link> + tree traversal.</para> + </figure> + + <figure xml:id="fig_XpathFollowingSiblings"> + <title>Following siblings</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para><tag class="starttag">a</tag>Two<tag + class="endtag">a</tag></para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>following-sibling::*</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b> + <a>One</a> + <a>Two</a> + <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> + <emphasis role="red"><x></emphasis>Four<emphasis role="red"></x></emphasis> + <emphasis role="red"><a></emphasis>Five<emphasis role="red"></a></emphasis> + </b> + <c>Mixed<a>content></a>Example</c> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <para><abbrev xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> + provides <link xlink:href="https://www.w3.org/TR/xpath#axes">different + axis definitions</link>:</para> + + <figure xml:id="sda1_fig_disjointAxeSets"> + <title>Disjoint <acronym + xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> axis + definitions.</title> + + <mediaobject> + <imageobject> + <imagedata fileref="Ref/Fig/preceding.fig"/> + </imageobject> + + <caption> + <para>The sets defined by ancestor, descendant, following, + preceding and self are disjoint. Their union equals the set of all + document nodes.</para> + </caption> + </mediaobject> + </figure> + + <figure xml:id="fig_XpathFollowingSiblingsRestricted"> + <title>Element restricted following siblings</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para><tag class="starttag">a</tag>Two<tag + class="endtag">a</tag></para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>following-sibling::a</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b> + <a>One</a> + <a>Two</a> + <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> + <x>Four</x> + <emphasis role="red"><a></emphasis>Five<emphasis role="red"></a></emphasis> + </b> + <c>Mixed<a>content></a>Example</c> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathText"> + <title>Elements containing non-whitespace text</title> + + <informaltable border="1"> + <colgroup width="39%"/> + + <colgroup width="61%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//*[text()[0 &lt; + string-length(normalize-space(.))]]</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b id="first"> + <emphasis role="red"><a></emphasis>A house<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Rent a car<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Two houses<emphasis role="red"></a></emphasis> + <emphasis role="red"><a></emphasis>Five<emphasis role="red"></a></emphasis> + </b> + <emphasis role="red"><c></emphasis>Building a house<emphasis + role="red"></c></emphasis> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathFollowingText"> + <title>Elements containing text containing <emphasis + role="red">'house'</emphasis></title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//*[text()[contains(., <emphasis + role="red">'house'</emphasis>)]]</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b id="first"> + <emphasis role="red"><a></emphasis>A house<emphasis role="red"></a></emphasis> + <a>Rent a car</a> + <emphasis role="red"><a></emphasis>Two houses<emphasis role="red"></a></emphasis> + <a>Five</a> + </b> + <emphasis role="red"><c></emphasis>Building a house<emphasis + role="red"></c></emphasis> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="fig_XpathLongText"> + <title>Elements containing text of minimal length</title> + + <informaltable border="1"> + <colgroup width="43%"/> + + <colgroup width="57%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//*[text()[7 &lt; + string-length(normalize-space(.))]]</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b id="first"> + <a>A house</a> + <a>Rent a car</a> + <emphasis role="red"><a></emphasis>Two houses<emphasis role="red"></a></emphasis> + <a>Five</a> + </b> + <emphasis role="red"><c></emphasis>Building a house<emphasis + role="red"></c></emphasis> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="sda1_fig_xpathAttribSearch"> + <title>Searching for attribute presence</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//*[@id]</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <emphasis role="red"><b </emphasis>id="start"<emphasis role="red">></emphasis> + <a>A house</a> + <a>Rent a car</a> + <a>Two houses </a> + <a>Five</a> + </b> + <emphasis role="red"><c</emphasis> id="build"<emphasis role="red">></emphasis>Building a house<emphasis + role="red"></c></emphasis> +</top></programlisting></td> + </tr> + </informaltable> + </figure> + + <figure xml:id="sda1_fig_xpathAttribSearchValue"> + <title>Searching for attribute value</title> + + <informaltable border="1"> + <colgroup width="30%"/> + + <colgroup width="70%"/> + + <tr> + <td valign="top"><glosslist> + <glossentry> + <glossterm>Context node</glossterm> + + <glossdef> + <para>-</para> + </glossdef> + </glossentry> + + <glossentry> + <glossterm>XPath</glossterm> + + <glossdef> + <para><code>//*[@id='build']</code></para> + </glossdef> + </glossentry> + </glosslist></td> + + <td valign="top"><programlisting language="xml"><top> + <b id="first"> + <a>A house</a> + <a>Rent a car</a> + <a>Two houses </a> + <a>Five</a> + </b> + <emphasis role="red"><c</emphasis> id="build"<emphasis role="red">></emphasis>Building a house<emphasis + role="red"></c></emphasis> +</top></programlisting></td> + </tr> + </informaltable> + </figure> </section> <section xml:id="sda1_xmlschema_sect_uniquenessConstraints"> @@ -1753,6 +2532,196 @@ key "primaryKey". --></emphasis> </appointment> </programlisting> </figure> + + <qandaset defaultlabel="qanda" + xml:id="sda1_xmlschema_qanda_memoExtended"> + <title>Representing extended <tag class="starttag">memo</tag> + instances</title> + + <qandadiv> + <qandaentry> + <question> + <para>This exercise is about representing an online messaging + system's data store:</para> + + <programlisting language="none"><memo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="memo.xsd" + date="2014-09-24" <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-1" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-1-co"/> priority="medium" <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-2" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-2-co"/>> + <contacts> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-3" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-3-co"/> + <entry id="10"> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-4" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-4-co"/> + <commonName>Susan Sonntag</commonName> + <tel>+44332232323</tel> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-5" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-5-co"/> + <email>susan23@evermail.com</email> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-6" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-6-co"/> + <email>susa112@private.uk</email> + </entry> + <entry id="20"> + <commonName>John Balber</commonName> + <email>balber@hatebook.com</email> + <tel>017297123232</tel> + <email>home@balber.org</email> + </entry> + <entry id="25"> + <commonName>Mary Palmer</commonName> + <tel>017297123232</tel> + </entry> + </contacts> + + <from contact="10"/> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-7" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-7-co"/> + <to contact="20"/> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-8" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-8-co"/> + <to contact="25"/> + <subject>Best whishes</subject> + <content> + <para>Have a nice trip!</para> + <para>I feel <emphasis>very</emphasis> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-9" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-9-co"/> happy for you. Don't miss <link href="https://www.wikipedia.org"> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-10" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-10-co"/> sharing your results</link>.</para> <co + linkends="sda1_xmlschema_qanda_memoExtendedExampleData-11" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-11-co"/> + </content> +</memo></programlisting> + + <calloutlist> + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-1-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-1"> + <para>Mandatory <property>@date</property> attribute of + appropriate type.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-2-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-2"> + <para>Optional <property>@priority</property> attribute + allowing exactly one of {<code>low</code>, + <code>medium</code>, <code>high</code>}.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-3-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-3"> + <para><tag class="starttag">contacts</tag> defining a list + of contacts having at least one <tag + class="starttag">entry</tag>.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-4-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-4"> + <para>Each <tag class="starttag">entry</tag> represents an + individual contact having a unique <property>@id</property> + value. Rules:</para> + + <itemizedlist> + <listitem> + <para>An <tag class="starttag">entry</tag> must have at + least one <tag class="starttag">email</tag> or <tag + class="starttag">tel</tag> child.</para> + </listitem> + + <listitem> + <para><tag class="starttag">email</tag> and <tag + class="starttag">tel</tag> children may appear in + arbitrary order. Hint: Watch out for the <tag + class="starttag">xs:choice</tag> definition.</para> + </listitem> + </itemizedlist> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-5-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-5"> + <para>A telephone number is subject to the following + restrictions:</para> + + <itemizedlist> + <listitem> + <para>A telephone number must start either with + <quote>0</quote> or <quote>+</quote>.</para> + </listitem> + + <listitem> + <para>Apart from a <quote>+</quote> sign at the very + beginning only digits are allowed.</para> + </listitem> + + <listitem> + <para>If starting with an (international) + indicator + the next character must not be zero. A <quote>+</quote> + indicator must be followed by at least three digits (two + representing the country code plus at least one + <quote>national</quote> digit).</para> + </listitem> + </itemizedlist> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-6-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-6"> + <para>Consider <xref + linkend="sda1_xmlschema_fig_organizerEmailUserType"/>.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-7-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-7"> + <para>The <tag class="starttag">from</tag> element + represents the memo's sender with + <property>@contact</property> referring to an <tag + class="starttag">entry</tag> element. A <tag + class="starttag">memo</tag> has got exactly one + sender.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-8-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-8"> + <para>Likewise each <tag class="starttag">to</tag> element + represents a recipient. All recipients form a set (having no + duplicates). Thus within a given <tag + class="starttag">memo</tag> all @contact attribute values + appearing in <tag class="starttag">to</tag> elements must be + unique.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-9-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-9"> + <para>para elements allow for mixed content possibly + containing both <tag class="starttag">emphasis</tag> and + <tag class="starttag">link</tag> children. An <tag + class="starttag">emphasis</tag> element's formatting + expectation is <abbrev>e.g.</abbrev> using bold font + weight.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-10-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-10"> + <para><tag class="starttag">link</tag> elements are the + equivalent to the <xref linkend="glo_HTML"/> <tag + class="starttag">a href="..."</tag> element. Hint: <xref + linkend="glo_XSD"/> offers a type suitable for URI + strings.</para> + </callout> + + <callout arearefs="sda1_xmlschema_qanda_memoExtendedExampleData-11-co" + xml:id="sda1_xmlschema_qanda_memoExtendedExampleData-11"> + <para>There must be at least one <tag + class="starttag">para</tag> child within <tag + class="starttag">content</tag>.</para> + </callout> + </calloutlist> + </question> + </qandaentry> + </qandadiv> + </qandaset> </section> <section xml:id="sda1_xmlschema_sect_bestPractices"> diff --git a/Doc/Sda1/xslt.xml b/Doc/Sda1/xslt.xml index acfc22c3ffa7afda415163eaba163b0a91d8bcbd..5c6eb893e0678511c6e6c05ef83c813b5bef34b3 100644 --- a/Doc/Sda1/xslt.xml +++ b/Doc/Sda1/xslt.xml @@ -339,741 +339,6 @@ Martin Goik</computeroutput></screen> </calloutlist> </section> - <section xml:id="xpath"> - <title><link xlink:href="https://www.w3.org/TR/xpath">XPath</link> and - node sets</title> - - <para><xref linkend="glo_SQL"/> allows for predicate base queries - returning a set of data records:</para> - - <figure xml:id="sda1_fig_sqlQueryPrinciple"> - <title><xref linkend="glo_SQL"/> query result</title> - - <informaltable border="0"> - <tr> - <th>Query</th> - - <th>Set</th> - </tr> - - <tr> - <td valign="top"><programlisting language="sql">SELECT name, email -from Customer -WHERE dept='finance' - or category = 12</programlisting></td> - - <td valign="top"><screen>{ - ('John Yates', 'yates@company.com'), - ('Sandra Barnes', 'barnes@testcenter.org'), -... -}</screen></td> - </tr> - </informaltable> - </figure> - - <para>Likewise the <acronym - xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> standard allows - for predicate based queries on XML documents retrieving node sets. Thus - its role may be compared to <xref linkend="glo_SQL"/> <code>SELECT</code> - ... <code>FROM</code> ...<code>WHERE</code> queries. Some simple - examples:</para> - - <figure xml:id="sda1_fig_sqlXpathCompare"> - <title>Comparing <xref linkend="glo_SQL"/> and <xref - linkend="glo_XPath"/></title> - - <para>Predicate based queries:</para> - - <informaltable border="1"> - <tr> - <td valign="top"><programlisting language="sql">SELECT name, email -from Customer -WHERE dept='finance' - or category = 12</programlisting></td> - - <td valign="top"><programlisting language="xml"><database> - ... - <customer dept='finance'>... - -</database></programlisting><programlisting language="xslt">/database//customer[@dept='finance' - or category='7']</programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="sda1_fig_sqlXpathCommonDifferent"> - <title>Similarities and differences</title> - - <para>Predicate base queries:</para> - - <informaltable border="1"> - <tr> - <th><xref linkend="glo_SQL"/></th> - - <th><xref linkend="glo_XPath"/></th> - </tr> - - <tr> - <td align="center" colspan="2" valign="top"><itemizedlist> - <listitem> - <para>Predicate based queries using boolean algebra</para> - </listitem> - </itemizedlist></td> - </tr> - - <tr> - <td valign="top"><itemizedlist> - <listitem> - <para>Joins</para> - </listitem> - - <listitem> - <para><quote>Flat</quote> data</para> - </listitem> - </itemizedlist></td> - - <td valign="top"><itemizedlist> - <listitem> - <para>Hierarchical data support</para> - </listitem> - - <listitem> - <para>Polymorphic results</para> - </listitem> - </itemizedlist></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathExamples"> - <title>Simple <acronym - xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> queries</title> - - <mediaobject> - <imageobject> - <imagedata fileref="Ref/Fig/xpath.fig" scale="65"/> - </imageobject> - </mediaobject> - </figure> - - <figure xml:id="sda1_fig_xpathFileSystemAnalogyRelative"> - <title>Relative file system search using <command - xlink:href="https://shapeshed.com/unix-find">find</command></title> - - <para>Starting from relative directory context:</para> - - <programlisting language="bash">find . -type d -name Gyre-P\*</programlisting> - - <para>Result:</para> - - <screen>./HTML-CSS/fonts/Gyre-Pagella -./SVG/fonts/Gyre-Pagella</screen> - </figure> - - <figure xml:id="sda1_fig_xpathFileSystemAnalogyAbsolute"> - <title><command - xlink:href="https://shapeshed.com/unix-find">find</command> starting - from absolute path</title> - - <para>Starting from absolute directory context:</para> - - <programlisting language="bash">find /etc/ -type f -and -name pac\*</programlisting> - - <para>Result:</para> - - <screen>/etc/brltty/Input/fs/pacmate.ktb -/etc/gnome-app-install/packages-whitelist</screen> - </figure> - - <figure xml:id="fig_XpathContextNodeEx1"> - <title><xref linkend="glo_XPath"/> and context nodes</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para><tag class="starttag">top</tag></para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>b/a</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b id="first"> - <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Four<emphasis role="red"></a></emphasis> - </b> - <c>Mixed<a>content></a>Example</c> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathContextNodeEx2"> - <title>Union</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para><tag class="starttag">top</tag></para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>(b|c)</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <emphasis role="red"><b id="first"></emphasis> - <a>One</a> - <a>Two</a> - <a>Three</a> - <a>Four</a> - <emphasis role="red"></b></emphasis> - <emphasis role="red"><c></emphasis>Mixed<a>content></a>Example<emphasis - role="red"></c></emphasis> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathContextNodeUnionDescent"> - <title>Union / descent</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para><tag class="starttag">top</tag></para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>(b|c)/a</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b> - <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Four<emphasis role="red"></a></emphasis> - </b> - <c>Mixed <emphasis role="red"><a></emphasis>content<emphasis - role="red"></a> </emphasis>Example</c> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathContextNodeEx3"> - <title>Recursive search for element name</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//a</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b> - <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Four<emphasis role="red"></a></emphasis> - </b> - <c>Mixed <emphasis role="red"><a></emphasis>content<emphasis - role="red"></a> </emphasis>Example</c> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathContextNodeRecursivePlusIndex"> - <title>Recursive + index search</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//a[2]</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b> - <a>One</a> - <emphasis role="red"><a></emphasis>Two<emphasis role="red"></a></emphasis> - <a>Three</a> - <a>Four</a> - </b> - <c>Mixed<a>content></a>Example</c> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathContextNodeSurprise"> - <title>Surprise!</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//a[1]</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b> - <emphasis role="red"><a></emphasis>One<emphasis role="red"></a></emphasis> - <a>Two</a> - <a>Three</a> - <a>Four</a> - </b> - <c>Mixed<emphasis role="red"><a></emphasis>content><emphasis - role="red"></a></emphasis>Example</c> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="sda1_fig_siblings"> - <title>Siblings</title> - - <glosslist> - <glossentry> - <glossterm><code>preceeding-siblings::*</code></glossterm> - - <glossdef> - <para>All nodes having the same parent node as the content node - and appearing <quote>before</quote> the context node.</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm><code>following-siblings::*</code></glossterm> - - <glossdef> - <para>All nodes having the same parent node as the content node - and appearing <quote>after</quote> the context node.</para> - </glossdef> - </glossentry> - </glosslist> - - <para><quote>Before</quote> and <quote>after</quote> with respect to - <link - xlink:href="https://en.wikipedia.org/wiki/Depth-first_search">depth-first</link> - tree traversal.</para> - </figure> - - <figure xml:id="fig_XpathFollowingSiblings"> - <title>Following siblings</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para><tag class="starttag">a</tag>Two<tag - class="endtag">a</tag></para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>following-sibling::*</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b> - <a>One</a> - <a>Two</a> - <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> - <emphasis role="red"><x></emphasis>Four<emphasis role="red"></x></emphasis> - <emphasis role="red"><a></emphasis>Five<emphasis role="red"></a></emphasis> - </b> - <c>Mixed<a>content></a>Example</c> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <para><abbrev xlink:href="https://www.w3.org/TR/xpath">XPath</abbrev> - provides <link xlink:href="https://www.w3.org/TR/xpath#axes">different - axis definitions</link>:</para> - - <figure xml:id="sda1_fig_disjointAxeSets"> - <title>Disjoint <acronym - xlink:href="https://www.w3.org/TR/xpath">XPath</acronym> axis - definitions.</title> - - <mediaobject> - <imageobject> - <imagedata fileref="Ref/Fig/preceding.fig"/> - </imageobject> - - <caption> - <para>The sets defined by ancestor, descendant, following, preceding - and self are disjoint. Their union equals the set of all document - nodes.</para> - </caption> - </mediaobject> - </figure> - - <figure xml:id="fig_XpathFollowingSiblingsRestricted"> - <title>Element restricted following siblings</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para><tag class="starttag">a</tag>Two<tag - class="endtag">a</tag></para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>following-sibling::a</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b> - <a>One</a> - <a>Two</a> - <emphasis role="red"><a></emphasis>Three<emphasis role="red"></a></emphasis> - <x>Four</x> - <emphasis role="red"><a></emphasis>Five<emphasis role="red"></a></emphasis> - </b> - <c>Mixed<a>content></a>Example</c> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathText"> - <title>Elements containing non-whitespace text</title> - - <informaltable border="1"> - <colgroup width="39%"/> - - <colgroup width="61%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//*[text()[0 &lt; - string-length(normalize-space(.))]]</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b id="first"> - <emphasis role="red"><a></emphasis>A house<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Rent a car<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Two houses<emphasis role="red"></a></emphasis> - <emphasis role="red"><a></emphasis>Five<emphasis role="red"></a></emphasis> - </b> - <emphasis role="red"><c></emphasis>Building a house<emphasis - role="red"></c></emphasis> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathFollowingText"> - <title>Elements containing text containing <emphasis - role="red">'house'</emphasis></title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//*[text()[contains(., <emphasis - role="red">'house'</emphasis>)]]</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b id="first"> - <emphasis role="red"><a></emphasis>A house<emphasis role="red"></a></emphasis> - <a>Rent a car</a> - <emphasis role="red"><a></emphasis>Two houses<emphasis role="red"></a></emphasis> - <a>Five</a> - </b> - <emphasis role="red"><c></emphasis>Building a house<emphasis - role="red"></c></emphasis> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="fig_XpathLongText"> - <title>Elements containing text of minimal length</title> - - <informaltable border="1"> - <colgroup width="43%"/> - - <colgroup width="57%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//*[text()[7 &lt; - string-length(normalize-space(.))]]</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b id="first"> - <a>A house</a> - <a>Rent a car</a> - <emphasis role="red"><a></emphasis>Two houses<emphasis role="red"></a></emphasis> - <a>Five</a> - </b> - <emphasis role="red"><c></emphasis>Building a house<emphasis - role="red"></c></emphasis> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="sda1_fig_xpathAttribSearch"> - <title>Searching for attribute presence</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//*[@id]</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <emphasis role="red"><b </emphasis>id="start"<emphasis role="red">></emphasis> - <a>A house</a> - <a>Rent a car</a> - <a>Two houses </a> - <a>Five</a> - </b> - <emphasis role="red"><c</emphasis> id="build"<emphasis role="red">></emphasis>Building a house<emphasis - role="red"></c></emphasis> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - - <figure xml:id="sda1_fig_xpathAttribSearchValue"> - <title>Searching for attribute value</title> - - <informaltable border="1"> - <colgroup width="30%"/> - - <colgroup width="70%"/> - - <tr> - <td valign="top"><glosslist> - <glossentry> - <glossterm>Context node</glossterm> - - <glossdef> - <para>-</para> - </glossdef> - </glossentry> - - <glossentry> - <glossterm>XPath</glossterm> - - <glossdef> - <para><code>//*[@id='build']</code></para> - </glossdef> - </glossentry> - </glosslist></td> - - <td valign="top"><programlisting language="xml"><top> - <b id="first"> - <a>A house</a> - <a>Rent a car</a> - <a>Two houses </a> - <a>Five</a> - </b> - <emphasis role="red"><c</emphasis> id="build"<emphasis role="red">></emphasis>Building a house<emphasis - role="red"></c></emphasis> -</top></programlisting></td> - </tr> - </informaltable> - </figure> - </section> - <section xml:id="sda1_sect_memoRecipents"> <title>Example: <tag class="element">memo</tag> recipients</title> diff --git a/Doc/lectures.xml b/Doc/lectures.xml index 8905284839ca15efb080b665bee2da0f27ddab75..71480e4ec3d5792b99972f27a0a9e34fe46f767a 100644 --- a/Doc/lectures.xml +++ b/Doc/lectures.xml @@ -90,7 +90,7 @@ xlink:href="https://en.wikipedia.org/wiki/EPUB">Epub</productname> reader applications do vary supporting <xref linkend="glo_EPUB"/> 3.0 (<abbrev>e.g.</abbrev> formulas and <xref linkend="glo_SVG"/> - images). Reader apps known to work well:</para> + images).</para> </caution> <para>Reader apps known to work well:</para>