Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #19184
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'transform': 0.07; 'python': 0.08; '[],': 0.09; 'dict': 0.09; 'object?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'adam': 0.16; 'does,': 0.16; 'from:addr:behnel.de': 0.16; 'from:addr:stefan_ml': 0.16; 'from:name:stefan behnel': 0.16; 'lookup': 0.16; 'overloaded': 0.16; 'subject:lxml': 0.16; 'url:lxml': 0.16; 'williams,': 0.16; 'working.': 0.18; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'dictionary': 0.23; 'stefan': 0.24; 'code': 0.25; 'parameters': 0.25; 'import': 0.27; "i'm": 0.27; 'work.': 0.28; 'pass': 0.28; 'explicit': 0.28; 'seem': 0.29; "i've": 0.31; 'source': 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.33; 'object': 0.33; 'received:84': 0.34; 'subject:/': 0.34; 'function.': 0.34; 'header:X-Complaints-To:1': 0.34; 'variables': 0.36; 'but': 0.37; 'received:org': 0.37; 'using': 0.37; 'should': 0.38; 'plain': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.40; 'according': 0.60; 'your': 0.61; 'here:': 0.67; 'url:extensions': 0.84; 'xslt': 0.84; 'story.': 0.95 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Stefan Behnel <stefan_ml@behnel.de> |
| Subject | Re: etree/lxml/XSLT and dynamic stylesheet variables |
| Date | Sat, 21 Jan 2012 05:56:32 +0100 |
| References | <1327091891.5020.12.camel@linux-dauq.site> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | dslb-084-056-048-126.pools.arcor-ip.net |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 |
| In-Reply-To | <1327091891.5020.12.camel@linux-dauq.site> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4904.1327121806.27778.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1327121806 news.xs4all.nl 6842 [2001:888:2000:d::a6]:50241 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:19184 |
Show key headers only | View raw
Adam Tauno Williams, 20.01.2012 21:38:
> I'm using etree to perform XSLT transforms, such as -
>
> from lxml import etree
> source = etree.parse(self.rfile)
> xslt = etree.fromstring(self._xslt)
> transform = etree.XSLT(xslt)
> result = transform(source)
>
> according to the docs at
> <http://lxml.de/xpathxslt.html#stylesheet-parameters> I can pass a
> dictionary of parameters to transform, such as -
>
> result = transform(doc_root, **{'non-python-identifier': '5'})
>
> Can I pass a dictionary-like object? That doesn't seem to be working.
Yes it does, Python copies it into a plain dict at call time.
> I need to perform dynamic lookup of variables for the stylesheet.
Different story.
> I've subclassed dictionary and overloaded [], get, has_key, and in to
> perform the required lookups; these work in testing. But passing the
> object to transform doesn't work.
You should make the lookup explicit in your XSLT code using an XPath
function. See here:
http://lxml.de/extensions.html
Stefan
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: etree/lxml/XSLT and dynamic stylesheet variables Stefan Behnel <stefan_ml@behnel.de> - 2012-01-21 05:56 +0100
csiph-web