source: products/quintagroup.transmogrifier/trunk/quintagroup/transmogrifier/xslt.txt @ 275

Last change on this file since 275 was 275, checked in by mylan, 18 years ago

Removed file/folder

File size: 1.9 KB
Line 
1XSLT section
2============
3
4A XSLT pipeline section lets you apply stylesheet to some XML data stored on
5item. The XSLT section blueprint name is ``quintagroup.transmogrifier.xslt``.
6
7That data need to be transformed is determined by ``source`` option. It gives
8the key in dictionay where data is stored. Dictionary is standard structure
9for storing files data in other our sections. It's stored on item on ``_files``
10key, but this can be changed with ``files-key`` option.
11
12Usually stylesheets are used to transform data returned by ``marshall`` section.
13We register those stylesheets in ZCML with special directive, for example:
14
15    <stylesheet xmlns="http://namespaces.zope.org/transmogrifier"
16        from="OldPortalType"
17        to="NewPortalType"
18        source="marshall"
19        file="path/to/stylesheet.xsl"
20        />
21
22``source`` atribute in this directive is similar to that in section option.
23
24Which stylesheet to use is determined for every pipeline item by inspecting
25it's values stored on keys specified in ``from-key`` and ``to-key`` section
26options. If item don't has those keys, it will be skepped.
27
28>>> xslt = """
29... [transmogrifier]
30... pipeline =
31...     xsltsource
32...     xslt
33...     printer
34...
35... [xsltsource]
36... blueprint = quintagroup.transmogrifier.tests.xsltsource
37...
38... [xslt]
39... blueprint = quintagroup.transmogrifier.xslt
40... source = marshall
41... from-key = _old_type
42... to-key = _type
43...
44... [printer]
45... blueprint = collective.transmogrifier.sections.tests.pprinter
46... """
47>>> registerConfig(u'quintagroup.transmogrifier.tests.xslt', xslt)
48>>> transmogrifier(u'quintagroup.transmogrifier.tests.xslt') # doctest: +ELLIPSIS
49{}
50{'_type': 'Weblog'}
51{'_old_type': 'Blog'}
52{'_files': {'manifest': {'data': 'xml', 'name': 'manifest.xml'}},
53 '_old_type': 'Blog',
54 '_type': 'Weblog'}
55{'_files': {'marshall': {'data': 'transformed xml', 'name': 'marshall.xml'}},
56 '_old_type': 'Blog',
57 '_type': 'Weblog'}
Note: See TracBrowser for help on using the repository browser.