|
From: Derek F. <fo...@hu...> - 2002-09-06 08:49:32
|
I'm creating a tree from scratch, and want to get a processing instruction in
at the top. I want, for example, this:
<?xml version="1.0">
<?xml-stylesheet type="text/xsl" href="test_view.xsl"?>
<!DOCTYPE test SYSTEM "test.dtd">
<test />
How do I get the stylesheet PI in there? I have a bit of code like this:
#!/bin/sh
# \
exec tclsh8.3 "$0" "$@"
package require xml
package require dom
set doc [::dom::DOMImplementation create]
set testNode [::dom::document createElement $doc "test"]
dom::document createProcessingInstruction \
$doc "xml-stylesheet" {type="text/xsl" href="test_view.xsl"}
puts [::dom::DOMImplementation serialize $doc]
which produces:
<?xml version='1.0'?>
<!DOCTYPE test>
<test/>
i.e. no PI at all. If I change the target node for the PI from $doc to
$testNode I get:
<?xml version='1.0'?>
<!DOCTYPE test>
<test><?xml-stylesheet type="text/xsl" href="test_view.xsl"?></test>
i.e. PI now serialised, but in the wrong place.
How do I get the PI at the top where I want it? I'm using Activetcl-8.3.4.3
with tclxml-2.2 and tclxml-2.0, and neither seem to give the result I'm after
the way I'm doing it.
--
The past: Smart users in front of dumb terminals
|