Adding processing instruction attributes to x-document

Posted by Admin on 11-Apr-2008 05:42

Hi. I would like to know how to add processing instructions to an X-DOCUMENT. My approach this far is more or less from the "Using xml with the progress 4GL" whitepaper. I have an x-document handle and tries to add a pi like this:

CREATE X-DOCUMENT hDoc.

CREATE X-NODEREF hPI.

hDoc:CREATE-NODE(hPI,"xml-stylesheet", "PROCESSING-INSTRUCTION").

hDoc:APPEND-CHILD(hPI).

This works as expected, but before I add the PI node to the document I'd like to complement it with some arguments like type="text/xsl" and href="./myxsl.xsl". It seems that it should not be forbidden to use something like:

hPI:SET-ATTRIBUTE("type", "text/xsl").

But it renderes a runtime error with "... Invalid nodetype".

Does anyone know what I'm doing wrong here?

Thanks

/Andreas

All Replies

Posted by mresnick on 14-Apr-2008 11:12

Andreas,

XML processing instructions take the form of

pi-name pi-content?>

Where pi-content is any text but the string "?>". See http://www.w3.org/TR/REC-xml/#sec-pi.

For example, the following is a valid processing instruction.

In this case the name is "psdn", and the value is the rest of the text appearing before the closing "?>".

The way to set a value for the processing instruction is to use the NODE-VALUE attribute on the X-NODEREF handle.

So, rather than use

hPI:SET-ATTRIBUTE("type", "text/xsl").

use

hPI:NODE-VALUE='type="text/xml"'.

The confusion comes from the Associating Style Sheets with XML documents

Version 1.0 specification (http://www.w3.org/TR/xml-stylesheet/). It defines the single pi-content string to look like a list of XML attributes. If you look at this spec you'll see that that "attributes" are, in fact, referred to as pseudo-attributes.

Michael

This thread is closed