English 中文(简体)
• 改变多氯元元素树的分支
原标题:Doing an XSL transform of a branch of a Docbook element tree

我愿利用《国际空间法年鉴》作文,在不改变整个内容的情况下,提供文件的不同部分。

复杂的是,其中一些部件有<条码>和斜线;,其<条码>链接<>/条码>属性不在同一平线之内。 换言之,我想处理树的一个分支,包括<代码>和t;footnoteref>s,但不是<footnote>项。

我试图利用<条形码>xml的包裹这样做,产生了这一错误信息:

XSLTApplyError                            Traceback (most recent call last)

/var/www/mpd/<ipython console> in <module>()

/var/www/mpd/<ipython console> in <genexpr>((elt,))

/usr/lib/python2.6/dist-packages/lxml/etree.so in lxml.etree.XSLT.__call__ (src/lxml/lxml.etree.c:109204)()

XSLTApplyError: Internal error in xsltKeyFunction(): Could not get the document info of a context doc.

这是因为,例如:etree.XSLT(etree.parse( docbook.xsl))(有些_element)

使用正常<代码>xhtml风格sheets。 不过,我不期望它处理哪一种风格是使用Im。

是否有办法支持这样做? 或者,例如,在文件上,我是否打算对SLT进行修改,以修改<代码><footnoteref> 要素至<footnote> 要素,然后再作修改? 但是,这样就算不了工作,因为届时将有多个<代码><footnote>和相同的编号。 只有在以下情况下才能做到:<代码><footnoteref> to <footnote> transformation,条件是:<footnote> tag未被列入所产生的树。 我期待已经发生的情况。 但充满希望的是,我刚刚失去了一个开关。

<><>>>>><>>>>>><>>>>>

由于“Jukka”的回答,我已经指出,我可以通过 。 然而,它非常忠实地生产了产出,只是将脚注与作为单一超文本页而有用的相同。 EG

>>> xsl_url_html =  http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl 
>>> from lxml import etree
>>> consume_result = etree.XSLT(etree.parse(xsl_url_xhtml))(
        etree.parse(my_xml_file), rootid=etree.XSLT.strparam("command_consume"))
>>> etree.tostring(consume_result).split( 
 )
[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> ,
  <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ASCII" /><title></title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /></head><body><dt><a id="command_consume"></a><span class="term"> ,
              <div class="cmdsynopsis"><p><code class="command">consume</code>  {<em class="replaceable"><code>STATE</code></em>}</p></div> ,
            </span></dt><dd><p> ,
                <sup>[<a href="#ftn.since_0_15" class="footnoteref">2</a>]</sup> ,
                Sets consume state to <code class="varname">STATE</code>, ,
                <code class="varname">STATE</code> should be 0 or 1. ,
  	      When consume is activated, each song played is removed from playlist. ,
              </p></dd></body></html> ]

或许还有另一个参数,将使得脚注放在同一页上,最好从1页上编号? 我猜测可能出现在上。 当我获得更多时间时,我就坐下来了。

问题回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签