XSieve: XSLT+Scheme XSieve Extending XSLT with the roots of XSLT - - PowerPoint PPT Presentation

xsieve xslt scheme
SMART_READER_LITE
LIVE PREVIEW

XSieve: XSLT+Scheme XSieve Extending XSLT with the roots of XSLT - - PowerPoint PPT Presentation

XSieve: XSLT+Scheme XSieve Extending XSLT with the roots of XSLT Oleg Parashchenko Saint-Petersburg State University, Russia olpa@ http://uucode.com/blog/ http://xmlhack.ru/ 1 XSieve: XSLT+Scheme XTech 2006 Top secret XSieve is a


slide-1
SLIDE 1

— 1 — XSieve: XSLT+Scheme

XTech 2006

XSieve: XSLT+Scheme

Oleg Parashchenko Saint-Petersburg State University, Russia

  • lpa@ http://uucode.com/blog/

http://xmlhack.ru/

Extending XSLT with the roots of XSLT

XSieve

slide-2
SLIDE 2

— 2 — XSieve: XSLT+Scheme

XTech 2006

XSieve is a by-side product.

Top secret

slide-3
SLIDE 3

— 3 — XSieve: XSLT+Scheme

XTech 2006

Outline

  • XSieve vs alternatives
  • SXML format and tools
  • XSieve language
  • XSieve in practice
  • Technical details
  • Conclusion and further work
slide-4
SLIDE 4

— 4 — XSieve: XSLT+Scheme

XTech 2006

My featured skill is:

  • XML data transformation
  • Word to XML
  • Quicksilver, Interleave to XML
  • Unstructured FrameMaker to XML
  • Etc
  • XML to HTML, PDF, etc

Background

slide-5
SLIDE 5

— 5 — XSieve: XSLT+Scheme

XTech 2006

But XSLT fails. Data transformation should be supported by programming. XSLT is not a good programming language.

XSLT is the best

slide-6
SLIDE 6

— 6 — XSieve: XSLT+Scheme

XTech 2006

“elemname[i]" vs

/** * Returns child element at given position. Position can be * negative. In this case nodes are counting from end. * Last node position is '-1'. * @param node parent node * @param name name of node, null if not important * @param pos position of node starting from zero, can be negative */ public static Element getChildElement (Element node, String name, int s) { // // Update position to be always positive. // boolean fromEnd = pos < 0; if (fromEnd) { pos = -(pos + 1); } // // Initialize // Node cur_node = fromEnd ? node.getLastChild(): node.getFirstChild(); int cur_pos = -1; // // Walk on children // for (; cur_node != null; cur_node = (fromEnd ? cur_node.getPreviousSibling() : cur_node.getNextSibling ())) { // // Check that current node is of type 'element' // if (cur_node.getNodeType() != Node.ELEMENT_NODE) { continue; } // // Get element, check its name and position // Element cur_elem = (Element)cur_node; if ((name != null) && (! name.equals (cur_elem.getTagName()))) { continue; } cur_pos++; if (cur_pos == pos) { return cur_elem; } } // // If node was found, it was returned from inside loop // return null; }

Another language?

slide-7
SLIDE 7

— 7 — XSieve: XSLT+Scheme

XTech 2006

“Isomorphism” to XPath and XSLT Greenspun's Tenth Rule of Programming: “Any sufficiently complicated C or Fortran program contains an ad hoc informally- specified bug-ridden slow implementation

  • f half of Common Lisp”

My addition: the same for data transformation and XSLT.

Good library?

slide-8
SLIDE 8

— 8 — XSieve: XSLT+Scheme

XTech 2006

XSLT plus a programming language

  • XSLT extensions?
  • New XML languages?
  • Old languages?

The need

slide-9
SLIDE 9

— 9 — XSieve: XSLT+Scheme

XTech 2006

DSSSL

Scheme dialect, but not Scheme. Genealogy: XSieve XSLT Scheme DSSSL

slide-10
SLIDE 10

— 10 — XSieve: XSLT+Scheme

XTech 2006

  • Scheme
  • SXPath, SXSLT and more
  • Effective design
  • A separate sandbox

SXML library

slide-11
SLIDE 11

— 11 — XSieve: XSLT+Scheme

XTech 2006

XSLT A general-purpose programming language SXML Integration with XSLT

What XSieve fixes

slide-12
SLIDE 12

— 12 — XSieve: XSLT+Scheme

XTech 2006

“A gestalt entity is a physical, biological, psychological, or symbolic configuration

  • r pattern of elements, so unified as

a whole that its properties cannot be derived from a simple summation of its parts” — Wikipedia

Gestalt entity

slide-13
SLIDE 13

— 13 — XSieve: XSLT+Scheme

XTech 2006

Outline

  • XSieve vs alternatives
  • SXML format and tools
  • XSieve language
  • XSieve in practice
  • Technical details
  • Conclusion and further work
slide-14
SLIDE 14

— 14 — XSieve: XSLT+Scheme

XTech 2006

“Show me your code and conceal your data structures, and I shall continue to be mystified. Show me your data structures, and I won't usually need your code; it'll be obvious” Eric Raymond (1997), paraphrase of Frederick Brooks (1975)

SXML format

slide-15
SLIDE 15

— 15 — XSieve: XSLT+Scheme

XTech 2006

SXML format

(elem “text”) <elem>text</elem> <elem>text<sube>subtext</sube></elem> (elem “text” (sube “subtext”))

slide-16
SLIDE 16

— 16 — XSieve: XSLT+Scheme

XTech 2006

<?pi db as-table?> (*PI* db “as-table”) <!--TODO--> (*COMMENT* “TODO”) (*TOP* (... ))

SXML format

slide-17
SLIDE 17

— 17 — XSieve: XSLT+Scheme

XTech 2006

<elem a1=”val1” a2=”val2” /> (elem (@ (a1 “val1”) (a2 “val2”))

SXML format

slide-18
SLIDE 18

— 18 — XSieve: XSLT+Scheme

XTech 2006

x = (elem “a” (b) “c”) <elem>a<b/>c</elem> (car x) == name() (cdr x) == @* | node() (map func (query x)) ~ xsl:apply-templates

Navigation by hand

slide-19
SLIDE 19

— 19 — XSieve: XSLT+Scheme

XTech 2006

(elem1 elem2 @ attr) elem1/elem2/@attr (elem1 (elem2 condition) @ attr) elem1/elem2[condition]/@attr Custom Scheme steps, axes, predicates

SXPath

slide-20
SLIDE 20

— 20 — XSieve: XSLT+Scheme

XTech 2006

  • Local scoping of re-writing “templates”
  • First-class stylesheets
  • Traversal strategies
  • Ability to re-traverse the original or

transformed trees

SXSLT

slide-21
SLIDE 21

— 21 — XSieve: XSLT+Scheme

XTech 2006

Outline

  • XSieve vs alternatives
  • SXML format and tools
  • XSieve language
  • XSieve in practice
  • Technical details
  • Conclusion and further work
slide-22
SLIDE 22

— 22 — XSieve: XSLT+Scheme

XTech 2006

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns:s = "http://xsieve.sourceforge.net" extension-element-prefixes="s" version = "1.0"> <xsl:template match="/"> <s:scheme> (display (x:current))(newline) </s:scheme> </xsl:template> </xsl:stylesheet>

XSieve example

slide-23
SLIDE 23

— 23 — XSieve: XSLT+Scheme

XTech 2006

<xsl:template match="/"> <s:scheme> '(article (@ (id "hw")) (title "Hello") (para "Hello, " (object "World") "!")) </s:scheme> </xsl:template> <article id="hw"> <title>Hello</title> <para>Hello, <object>World</object>!</para> </article>

XSieve example

slide-24
SLIDE 24

— 24 — XSieve: XSLT+Scheme

XTech 2006

(x:eval xpath [basenode]) (x:apply-templates ['mode 'mode-name] ['with-param 'param1 value1 ...] ['with-param 'paramN valueN] nodeset)

More XSieve

slide-25
SLIDE 25

— 25 — XSieve: XSLT+Scheme

XTech 2006

<items> <item price="20" qty="2"/> ... <item price="50" qty="0"/> </items> (apply + (map (lambda (node) (* (x:eval "number(@qty)" node) (x:eval "number(@price)" node))) (x:eval "//item")))

Multiple sum

slide-26
SLIDE 26

— 26 — XSieve: XSLT+Scheme

XTech 2006

Outline

  • XSieve vs alternatives
  • SXML format and tools
  • XSieve language
  • XSieve in practice
  • Technical details
  • Conclusion and further work
slide-27
SLIDE 27

— 27 — XSieve: XSLT+Scheme

XTech 2006

(Re)grouping

<h2>Device</h2> <p>In this section...</p> <h3>Overview</h3> ... <h3>Maintenance</h3> <p>1. ...</p> <p>2. ...</p> ...

Device Overview Maintenance

slide-28
SLIDE 28

— 28 — XSieve: XSLT+Scheme

XTech 2006

OpenOffice hinting

<text:p text:style-name="P9">Some text</text:p> <text:p text:style-name="P9" fo:font-weight="bold" ><style-hint:name>P9</style-hint:name ><style-hint:name>Standard</style-hint:name >Some text</text:p>

slide-29
SLIDE 29

— 29 — XSieve: XSLT+Scheme

XTech 2006

Syntax highlighting

<programlisting role="xml"> &lt;para>Hello, <emphasis>&amp;who;</emphasis >!&lt;/para> <co id="who-entity"/> </programlisting> Default: <para>Hello, &who;!</para> (1) Highlighted: <para>Hello, &who;!</para> XSieve: <para>Hello, &who;!</para> (1) http://tohtml.com/dbsy/

slide-30
SLIDE 30

— 30 — XSieve: XSLT+Scheme

XTech 2006

Outline

  • XSieve vs alternatives
  • SXML format and tools
  • XSieve language
  • XSieve in practice
  • Technical details
  • Conclusion and further work
slide-31
SLIDE 31

— 31 — XSieve: XSLT+Scheme

XTech 2006

The executable

  • Standard XSLT extension
  • Scheme as the language
  • xsltproc plus Guile
  • xsltproc plugin
slide-32
SLIDE 32

— 32 — XSieve: XSLT+Scheme

XTech 2006

The main problems were

  • Uncertainty with results
  • S-expressions and XML are

different, incompatible creatures

slide-33
SLIDE 33

— 33 — XSieve: XSLT+Scheme

XTech 2006

Other problems were

  • XML ⇔ SXML: namespaces
  • Garbage collection and memory management
  • apply-templates from “s:scheme”
slide-34
SLIDE 34

— 34 — XSieve: XSLT+Scheme

XTech 2006

Correctness

DocBook stylesheets <xsl:apply-templates select=”xpath”/> <s:scheme> (x:apply-templates (x:eval “xpath”)) </s:scheme>

slide-35
SLIDE 35

— 35 — XSieve: XSLT+Scheme

XTech 2006

Performance

It depends.

  • Auto-generated: slow
  • OpenOffice hinting: very fast
  • Lazy instantiation: very slow
slide-36
SLIDE 36

— 36 — XSieve: XSLT+Scheme

XTech 2006

More implementations?

Java, .NET: problems are easier. XSieve: alternative or partner for EXSLT.

slide-37
SLIDE 37

— 37 — XSieve: XSLT+Scheme

XTech 2006

Outline

  • XSieve vs alternatives
  • SXML format and tools
  • XSieve language
  • XSieve in practice
  • Technical details
  • Development behind XSieve
  • Conclusion and further work
slide-38
SLIDE 38

— 38 — XSieve: XSLT+Scheme

XTech 2006

Generative XPath

  • Compilers
  • Text processors
  • Etc
  • Hard for C
  • XML virtual machine as Scheme plus SXML
slide-39
SLIDE 39

— 39 — XSieve: XSLT+Scheme

XTech 2006

Testing XPath

Test suite vs test-by-practice (x:apply-templates (x:eval “xpath”))

slide-40
SLIDE 40

— 40 — XSieve: XSLT+Scheme

XTech 2006

Main development

  • http://xmlhack.ru/protva/xquery/
  • Testing XML VM in C:
  • GNU find with XPath
  • libxml/libxslt
  • Testing generative XPath

by-side: XSieve

slide-41
SLIDE 41

— 41 — XSieve: XSLT+Scheme

XTech 2006

Outline

  • XSieve vs alternatives
  • SXML format and tools
  • XSieve language
  • XSieve in practice
  • Technical details
  • Conclusion and further work
slide-42
SLIDE 42

— 42 — XSieve: XSLT+Scheme

XTech 2006

Future work

  • XSieve is frozen
  • DocBook XSieve/TeXML stylesheets
slide-43
SLIDE 43

— 43 — XSieve: XSLT+Scheme

XTech 2006

New language

  • What does it look like?
  • Scheme and SXML in XSLT
  • What does it fix?
  • XML to programming language
  • SXML integration
  • Will I use it?
slide-44
SLIDE 44

— 44 — XSieve: XSLT+Scheme

XTech 2006

Thank you!

Oleg Parashchenko Saint-Petersburg State University, Russia

  • lpa@ http://uucode.com/blog/

http://xmlhack.ru/

Extending XSLT with the roots of XSLT

XSieve