Re: [xml] adding transformContexts to Python



Daniel Veillard <veillard redhat com> writes:

  Doesn't look crazy to me :-) Tell me if you want this to be applied
  as is or if you prefer doing a bit more testing,

I wrote a test for the resolver access:

  import libxslt
  import libxml2
  import sys
  import StringIO
  import pdb

  def xslt_resolver(url, id, ctxt):
      pctxt = libxslt.xpathParserContext(_obj=ctxt)
      xpc = pctxt.context()
      doc = xpc.contextDoc()

      if url == "someimport.xslt":
          f = StringIO.StringIO("""<?xml version="1.0" encoding="utf-8"?>
  <xsl:stylesheet  version="1.0"
                   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
      <xsl:template match="/xxx">
          <sexy/>
      </xsl:template>
  </xsl:stylesheet>
  """)
          return f
      return None

  def test():
      libxml2.setEntityLoader(xslt_resolver)
      src_doc = libxml2.parseDoc("<a/>")
      style_doc = libxml2.parseDoc("""<?xml version="1.0" encoding="utf-8"?>
      <xsl:stylesheet  version="1.0"
                       xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
          <xsl:import href="someimport.xslt"/>
          <xsl:template match="/">
              <goodbye/>
          </xsl:template>
      </xsl:stylesheet>
      """)

      style = libxslt.parseStylesheetDoc(style_doc)
      if style:
          transform_ctxt = style.newTransformContext(src_doc)
          result = style.applyStylesheetUser(src_doc, {}, transform_ctxt)
          result.dump(sys.stdout)

  pdb.runcall(test)


When I run this on UNPATCHED libxslt (deb 1.1.17-2) it segfaults at
line 9.

It appears that this function:

  libxsltmod.xsltXPathGetContextDoc

is the immediate cause of the fault... but I'm guessing the problem is
with the python code putting the values into the C.


I get the same problem with my patched code... can you shed any light
on this?

-- 
Nic Ferrier
http://www.tapsellferrier.co.uk   for all your tapsell ferrier needs



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]