Укрощение XML

                      Дмитрий Шабанов
                          eXist-db.org
                         animotron.org
                        twitter.com/shabanovd

http://exist-db.org
Мифы и реальность



         Когда используешь XML, то НЕ
                НАДО РАБОТАТЬ

        XML НЕ РЕШИТ Ваших проблем


http://exist-db.org
Мифы и реальность




                       XML — это формат
                        представления
                      данных и структуры


http://exist-db.org
Мифы и реальность



                      Стандарты

         договоренность достигнутая и
            принятая сообществом


http://exist-db.org
Стандарты - W3C

                  XML, HTML5, URI, PNG ...
                             ...
                          XQuery,
                   XSL, XSL-FO, XProc, …
                             ...
                   XForms, VoiceXML, …
                        MathML, ...
http://exist-db.org
Стандарты - OASIS



                        DocBook
                          DITA
                      OpenDocument
                         XACML
                           ….

http://exist-db.org
Стандарты - DocBook
    <article>
     <title>Writing DocBook articles</title>
     <artheader>
      <abstract>
    This article describes how you can use DocBook to develop PDF
    documents and will cover tools you need to edit DocBook articles and
    tools to translate them to PDF documents.
      </abstract>
      <author>
       <firstname>Egon</firstname>
       <surname>Willighagen</surname>
      </author>
      <date></date>
     </artheader>
    </article>
http://exist-db.org
Стандарты - DocBook




http://exist-db.org
Трансформации
                      http://nwalsh.com/docbook/procdiagram/




http://exist-db.org
XForms

    <xf:input id="first" ref="firstname">

     <xf:label>Firstname:</xf:label>

     <xf:hint>enter your firstname</xf:hint>

     <bf:data
       bf:readonly="false"
       bf:required="true"
       bf:type="string"/>

    </xf:input>


http://exist-db.org
XForms




                      XSLTForms

                      BetterFORM


http://exist-db.org
XQuery




                      Язык запросов

                         XQuery


http://exist-db.org
XQuery

    <PLAY>
     <TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE>
                                           ...
     <ACT>
      <TITLE>ACT I</TITLE>
      <SCENE>
      <TITLE>SCENE I. Elsinore. A platform before the castle.</...
                                           ...
      <SPEECH>
       <SPEAKER>BERNARDO</SPEAKER>
       <LINE>Who's there?</LINE>
      </SPEECH>
      <SPEECH>
       <SPEAKER>FRANCISCO</SPEAKER>
                                           ...

http://exist-db.org
XQuery
    <html><head/><body>
    {
      for $act in doc("hamlet.xml")//ACT
      let $speakers := distinct-values($act//SPEAKER)
      return
       <div>
        <h1>{ string($act/TITLE) }</h1>
        <ul>
        {
          for $speaker in $speakers
          return <li>{ $speaker }</li>
        }
        </ul>
       </div>
    }
    </body></html>
http://exist-db.org
XQuery


    <html><head/><body>
      <div>
       <h1>ACT I</h1>
       <ul>
        <li>BERNARDO</li>
        <li>FRANCISCO</li>
            ...
       </ul>
      </div>
       ...
    </body></html>


http://exist-db.org
XQuery


                         Язык запросов
                               и
                      функциональный язык
                       программирования

                            XQuery
http://exist-db.org
XQuery

    xquery version "3.0";

    declare namespace ex =
                                  "http://exist-db.org/xquery/ex";

    declare function ex:map($func, $list) {
       for $item in $list return $func($item)
    };

    (: Create an inline function and assign it to $f :)
    let $f := upper-case#1
    return
       ex:map($f, ("Hello ", "world!"))

http://exist-db.org
XQuery




                      map( function($x) { $x * $x }, 1 to 5 )




http://exist-db.org
XQuery Update Facility



                            Язык
                      модификации данных

                      XQuery Update Facility


http://exist-db.org
XQuery Update Facility

  <root>
    <message>Hello World</message>
  </root>


  let $doc := doc('/db/test.xml')/root

  let $update := insert node attribute foo {'bar'} into $doc

  return $doc


  <root foo="bar">
    <message>Hello World</message>
  </root>

http://exist-db.org
Принцип наследования

                      XPath

                                XSL
    XQuery
                              XSL-FO
    XQuery
    Update Facility
http://exist-db.org
Локоничней

     XQuery enables you to achieve high productivity
                    in your projects

      The Amazon XQuery Client Library was written
     with 80% less code than its equivalent written in
                          Java

                                    zorba-xquery.com


http://exist-db.org
Что почитать?




               http://en.wikibooks.org/wiki/XQuery




http://exist-db.org
XQuery processors

    BaseX
                           Berkeley DB XML
                                                        eXist-db
    DB2 9 with pureXML
                                                      MarkLogic
    MonetDB/XQuery
                                              MS SQL Server 2005
    Saxon
                                  Zorba
    http://www.rpbourret.com/xml/ProdsNative.htm

http://exist-db.org
XQuery processors



                      Stream

                        vs

                      Storage

http://exist-db.org
Этапы развития



                      XML-enabled

                          VS

                      Native XML

http://exist-db.org
Поколения




               4th generation of databases
                                        Juha Kontio




http://exist-db.org
XML Database




    http://exist-db.org/
http://exist-db.org
Кто использует?

                         U.S. State Department Office
                           of the Historian website

                reBiND project                               easyDITA

    University of Heidelberg
                                                University of Richmond
                                     …..
    Томский Политехнический Университет http://tpu.ru
                         ЗАО «МЦФЭР» http://mcfr.ru

http://exist-db.org
Как использует?



       I have successfully stored over 16,000,000 XML documents in
                    eXist-db … 1KB - 4KB each (~30Gb).

      Querying was still possible…, so it must have been 3< seconds.

                                                         Adam Retter




http://exist-db.org
XML Database

    ● REST (URL Rewriting)
    ● WebDAV

    ● Security:

      ● multiple realms


        LDAP, OAuth, OpenID
      ● Unix permissions model (bitmap)

      ● Access control list

    ● XQuery 3.0

    ● XSL (Saxon)

    ● EXPath: packaging & modules



http://exist-db.org
XML Database


    ●
     Content Extraction and Binary
    Resource Indexing
    ● Lucene

    ● JSON & HTML 5 serializer

    ● «Applications» concept




http://exist-db.org
Что можно сделать?



                         Быстро состряпать
                      форму для сбора данных
                                 и
                        дальнейший анализ
                       сохраненных данных.



http://exist-db.org
Что можно сделать?




                      Сбор и обработка данных




http://exist-db.org
Что можно сделать?




     Браузер читающий твиты используя механизм
    text-to-speech встроенный в браузер.




http://exist-db.org
Что можно сделать?




                        Разработать CMS
                              или
              систему управления бизнес процессами
                     для вашей организации.




http://exist-db.org
IDE




                      <oXygen/> XML editor

                        eXide — web IDE


http://exist-db.org
<oXygen/> XML editor




http://exist-db.org
eXide IDE




http://exist-db.org
Concepts: XRX




http://exist-db.org
Concepts: RESTXQ

                        RESTXQ
                                                Adam Retter's
                                        XML Prague 2012 paper
    declare

         %rest:path(“/say/hello/{$name}”)

    function local:say-hello($name) {
       <hello>{$name}</hello>
    };
http://exist-db.org
Concepts: Applications




        Database next stage: Applications
                   container



http://exist-db.org
....




                            Вопросы
                               и
                      возможно даже ответы


http://exist-db.org
.


                  Пожалуйста, поставьте
                  оценку моему докладу.

             Ваше мнение очень важно.

                        Спасибо!
http://exist-db.org

Укрощение XML

  • 1.
    Укрощение XML Дмитрий Шабанов eXist-db.org animotron.org twitter.com/shabanovd http://exist-db.org
  • 2.
    Мифы и реальность Когда используешь XML, то НЕ НАДО РАБОТАТЬ XML НЕ РЕШИТ Ваших проблем http://exist-db.org
  • 3.
    Мифы и реальность XML — это формат представления данных и структуры http://exist-db.org
  • 4.
    Мифы и реальность Стандарты договоренность достигнутая и принятая сообществом http://exist-db.org
  • 5.
    Стандарты - W3C XML, HTML5, URI, PNG ... ... XQuery, XSL, XSL-FO, XProc, … ... XForms, VoiceXML, … MathML, ... http://exist-db.org
  • 6.
    Стандарты - OASIS DocBook DITA OpenDocument XACML …. http://exist-db.org
  • 7.
    Стандарты - DocBook <article> <title>Writing DocBook articles</title> <artheader> <abstract> This article describes how you can use DocBook to develop PDF documents and will cover tools you need to edit DocBook articles and tools to translate them to PDF documents. </abstract> <author> <firstname>Egon</firstname> <surname>Willighagen</surname> </author> <date></date> </artheader> </article> http://exist-db.org
  • 8.
  • 9.
    Трансформации http://nwalsh.com/docbook/procdiagram/ http://exist-db.org
  • 10.
    XForms <xf:input id="first" ref="firstname"> <xf:label>Firstname:</xf:label> <xf:hint>enter your firstname</xf:hint> <bf:data bf:readonly="false" bf:required="true" bf:type="string"/> </xf:input> http://exist-db.org
  • 11.
    XForms XSLTForms BetterFORM http://exist-db.org
  • 12.
    XQuery Язык запросов XQuery http://exist-db.org
  • 13.
    XQuery <PLAY> <TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE> ... <ACT> <TITLE>ACT I</TITLE> <SCENE> <TITLE>SCENE I. Elsinore. A platform before the castle.</... ... <SPEECH> <SPEAKER>BERNARDO</SPEAKER> <LINE>Who's there?</LINE> </SPEECH> <SPEECH> <SPEAKER>FRANCISCO</SPEAKER> ... http://exist-db.org
  • 14.
    XQuery <html><head/><body> { for $act in doc("hamlet.xml")//ACT let $speakers := distinct-values($act//SPEAKER) return <div> <h1>{ string($act/TITLE) }</h1> <ul> { for $speaker in $speakers return <li>{ $speaker }</li> } </ul> </div> } </body></html> http://exist-db.org
  • 15.
    XQuery <html><head/><body> <div> <h1>ACT I</h1> <ul> <li>BERNARDO</li> <li>FRANCISCO</li> ... </ul> </div> ... </body></html> http://exist-db.org
  • 16.
    XQuery Язык запросов и функциональный язык программирования XQuery http://exist-db.org
  • 17.
    XQuery xquery version "3.0"; declare namespace ex = "http://exist-db.org/xquery/ex"; declare function ex:map($func, $list) { for $item in $list return $func($item) }; (: Create an inline function and assign it to $f :) let $f := upper-case#1 return ex:map($f, ("Hello ", "world!")) http://exist-db.org
  • 18.
    XQuery map( function($x) { $x * $x }, 1 to 5 ) http://exist-db.org
  • 19.
    XQuery Update Facility Язык модификации данных XQuery Update Facility http://exist-db.org
  • 20.
    XQuery Update Facility <root> <message>Hello World</message> </root> let $doc := doc('/db/test.xml')/root let $update := insert node attribute foo {'bar'} into $doc return $doc <root foo="bar"> <message>Hello World</message> </root> http://exist-db.org
  • 21.
    Принцип наследования XPath XSL XQuery XSL-FO XQuery Update Facility http://exist-db.org
  • 22.
    Локоничней XQuery enables you to achieve high productivity in your projects The Amazon XQuery Client Library was written with 80% less code than its equivalent written in Java zorba-xquery.com http://exist-db.org
  • 23.
    Что почитать? http://en.wikibooks.org/wiki/XQuery http://exist-db.org
  • 24.
    XQuery processors BaseX Berkeley DB XML eXist-db DB2 9 with pureXML MarkLogic MonetDB/XQuery MS SQL Server 2005 Saxon Zorba http://www.rpbourret.com/xml/ProdsNative.htm http://exist-db.org
  • 25.
    XQuery processors Stream vs Storage http://exist-db.org
  • 26.
    Этапы развития XML-enabled VS Native XML http://exist-db.org
  • 27.
    Поколения 4th generation of databases Juha Kontio http://exist-db.org
  • 28.
    XML Database http://exist-db.org/ http://exist-db.org
  • 29.
    Кто использует? U.S. State Department Office of the Historian website reBiND project easyDITA University of Heidelberg University of Richmond ….. Томский Политехнический Университет http://tpu.ru ЗАО «МЦФЭР» http://mcfr.ru http://exist-db.org
  • 30.
    Как использует? I have successfully stored over 16,000,000 XML documents in eXist-db … 1KB - 4KB each (~30Gb). Querying was still possible…, so it must have been 3< seconds. Adam Retter http://exist-db.org
  • 31.
    XML Database ● REST (URL Rewriting) ● WebDAV ● Security: ● multiple realms LDAP, OAuth, OpenID ● Unix permissions model (bitmap) ● Access control list ● XQuery 3.0 ● XSL (Saxon) ● EXPath: packaging & modules http://exist-db.org
  • 32.
    XML Database ● Content Extraction and Binary Resource Indexing ● Lucene ● JSON & HTML 5 serializer ● «Applications» concept http://exist-db.org
  • 33.
    Что можно сделать? Быстро состряпать форму для сбора данных и дальнейший анализ сохраненных данных. http://exist-db.org
  • 34.
    Что можно сделать? Сбор и обработка данных http://exist-db.org
  • 35.
    Что можно сделать? Браузер читающий твиты используя механизм text-to-speech встроенный в браузер. http://exist-db.org
  • 36.
    Что можно сделать? Разработать CMS или систему управления бизнес процессами для вашей организации. http://exist-db.org
  • 37.
    IDE <oXygen/> XML editor eXide — web IDE http://exist-db.org
  • 38.
  • 39.
  • 40.
  • 41.
    Concepts: RESTXQ RESTXQ Adam Retter's XML Prague 2012 paper declare %rest:path(“/say/hello/{$name}”) function local:say-hello($name) { <hello>{$name}</hello> }; http://exist-db.org
  • 42.
    Concepts: Applications Database next stage: Applications container http://exist-db.org
  • 43.
    .... Вопросы и возможно даже ответы http://exist-db.org
  • 44.
    . Пожалуйста, поставьте оценку моему докладу. Ваше мнение очень важно. Спасибо! http://exist-db.org