[xslt] embed stylessheets | accessing XHTML result tree

Dear list

Sorry for those who read xml too. But my hope is that may be some
XSL-expert has run into the same problem and I`m really stuck :(

I got two questions I've not been able to resolve after having read the
docs/Faq/MailingList/Code. I would like to use libxml/libxslt for XSLT.

1.) embed stylessheets and libxml/libxsl

I use this function to parse the stylesheet:

  xsltStylesheetPtr style_sheet =  xsltParseStylesheetFile(file);

So if I've got an XML like this

 ~/XML -> cat pi3.xml
 <?xml version="1.0"?>
 <?xml-stylesheet type="text/xsl" href="#style1"?>

I've got to get the stylesheet first so I can apply them.


 1.) AFAIC you can't use libxml to do this automatically.

 2.) How do I access the PI's?

  xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(contents.data(),
  if (ctxt == NULL) {
    printf("ctxt Null \n");
  xmlNodePtr cur;

  cur = ctxt->????????;

struct xmlParserCtxt doesn't seem to have a pointer to the PIs. I'm sure
I'm missing something here.

2.) I would like to access the transformed DOM-Tree or better XHTML-tree
just _before_ it gets serialized. (I want to manipulate the DOM so writing
it out and streaming it in is a no-no.)

What is the approch here:

I was thinking that this might return me the transformed tree

  xmlDocPtr res = xsltApplyStylesheet(style_sheet, doc, params);

  printf("\nTransformed DOM \n\n");

  cur = xmlDocGetRootElement(res);
  recursiveDown(cur);                   //prints DOM to stderr

This doesn't work.

What is the approach here?

Thanks a lot,

  Andreas Schlapbach      schlpbch@iam.unibe.ch
                "/home sweet /home."

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