You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Scott Vachalek <sc...@Integrisoft.COM> on 2002/04/19 01:51:14 UTC

Processing Instruction / Stylesheet

Hi folks,

I've seen a couple of recent messages regarding the same thing I'm stuck on, which is creating a DOM that contains a stylesheet processing instruction.  I think I know how to make the request, but the only problem is every way I try, I end up with a DOM006 error.  I suspect a bug but it's very possible I'm just doing something wrong.

Does anyone have a snippet of code that will do this and *actually works* on either 2.0.0 or 2.0.1?  I'll settle for any way to do it as long as it works.

This is what I'm trying:

  Document doc = db.newDocument();
  doc.appendChild( doc.createProcessingInstruction(
      "xml-stylesheet", "href=\"" + stylesheet + "\" type=\"text/xsl\"" ) );
  doc.appendChild( doc.createElement( "root" ) );

I've tried other ways to sneak it in, using DOMImplementation and insertBefore, etc. etc.  I always end up with a DOM006 error.

The weird thing is, I can put the PI *after* the root element with no complaint.  Any help is greatly appreciated!

--Scott

P.S. The link to this mailing list archive is wrong on the "Mailing Lists" page: http://xml.apache.org/mail.html   It goes to a dead page which redirects you to another wrong page...  if someone could kindly fix it I'm sure future newbies will appreciate the effort.