1 | XSLT section |
---|
2 | ============ |
---|
3 | |
---|
4 | A XSLT pipeline section lets you apply stylesheet to some XML data stored on |
---|
5 | item. The XSLT section blueprint name is ``quintagroup.transmogrifier.xslt``. |
---|
6 | |
---|
7 | That data need to be transformed is determined by ``source`` option. It gives |
---|
8 | the key in dictionay where data is stored. Dictionary is standard structure |
---|
9 | for storing files data in other our sections. It's stored on item on ``_files`` |
---|
10 | key, but this can be changed with ``files-key`` option. |
---|
11 | |
---|
12 | Usually stylesheets are used to transform data returned by ``marshall`` section. |
---|
13 | We 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 | |
---|
24 | Which stylesheet to use is determined for every pipeline item by inspecting |
---|
25 | it's values stored on keys specified in ``from-key`` and ``to-key`` section |
---|
26 | options. 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'} |
---|