[xml] embed stylessheets | accessing XHTML result tree



Dear list

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/xml" href="#style1"?>
 <doc/>

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

Questions:

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

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

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

  xmlParsePI(ctxt);
  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

--
  Andreas Schlapbach      schlpbch iam unibe ch
  http://www.iam.unibe.ch/~schlpbch
                 "/home sweet /home."





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