xml - XSLT with Python's lxml: Forbidden Variable? -


i'm trying transform xml xhtml using xslt. i'd using python, i'm not particularly attached library. following the directions here, i've been trying this:

from lxml import etree  xslt_root=etree.parse('editions.xsl') transform=etree.xslt(xslt_root) 

but error:

traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "xslt.pxi", line 406, in lxml.etree.xslt.__init__ (src/lxml/lxml.etree.c:136874) lxml.etree.xsltparseerror: forbidden variable 

i tried using this python script, uses libxslt, gives me these errors:

    forbidden variable compilation error: file editions.xsl line 283 element key xsl:key : 'match' pattern compilation failed '//tei:div/tei:ab/tei:ptr[@type='emendation'][@ana='#folger'] |// tei:rdg[contains(@wit,$rdg)]/tei:ptr[@type='emendation'][@ana='#folger']' forbidden variable compilation error: file editions.xsl line 284 element key xsl:key : 'match' pattern compilation failed '//tei:div/tei:ab/tei:ptr[@type='emendation'][@ana='#folger'] |// tei:rdg[contains(@wit,$rdg)]/tei:ptr[@type='emendation'][@ana='#folger']' forbidden variable compilation error: file editions.xsl line 285 element key xsl:key : 'match' pattern compilation failed '//tei:div/tei:ab/tei:ptr[@type='emendation'][@ana='#texta'] |// tei:rdg[contains(@wit,$rdg)]/tei:ptr[@type='emendation'][@ana='#texta']' forbidden variable compilation error: file editions.xsl line 286 element key xsl:key : 'match' pattern compilation failed '//tei:div/tei:ab/tei:ptr[@type='emendation'][@ana='#texta'] |// tei:rdg[contains(@wit,$rdg)]/tei:ptr[@type='emendation'][@ana='#texta']' forbidden variable compilation error: file editions.xsl line 287 element key xsl:key : 'match' pattern compilation failed '//tei:div/tei:ab/tei:ptr[@type='emendation'][@ana='#textb'] |// tei:rdg[contains(@wit,$rdg)]/tei:ptr[@type='emendation'][@ana='#textb']' forbidden variable compilation error: file editions.xsl line 288 element key xsl:key : 'match' pattern compilation failed '//tei:div/tei:ab/tei:ptr[@type='emendation'][@ana='#textb'] |// tei:rdg[contains(@wit,$rdg)]/tei:ptr[@type='emendation'][@ana='#textb']' traceback (most recent call last):   file "transform.py", line 21, in <module>     result = style.applystylesheet(doc, none) attributeerror: 'nonetype' object has no attribute 'applystylesheet' 

the xsl file i'm using here. it's professionally created, wouldn't think there big problems it.

is there way override error, can xml file transform in python? or there different way xslt won't getting errors time? transforming in browser (firefox) works fine, can't work in python.

i'm afraid contractor has let down. xslt specification says in section 12.2:

it error value of either use attribute or match attribute contain variablereference.

so key elements in lines 283 288 of editions.xsl not valid xslt because match attributes use path step tei:rdg[contains(@wit,$rdg)].

fortunately, $rdg simple constant defined @ line 183 'lemma', if change 6 occurrences of path step tei:rdg[contains(@wit,'lemma')] instead, should work you.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -