List of the processing-instruction names in a file?

Vincent Lefevre

Usenet Archive
Joined
Aug 11, 2002
Messages
60
Reaction score
0
How can I get the list of the processing-instruction names in a file?

I tried the Muenchian method; it works on the element names for instance, but if I replace * by processing-instruction to use it on the processing-instructions, I get nothing.
 

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
"Vincent Lefevre" wrote:

How can I get the list of the processing-instruction names in a file?

I tried the Muenchian method; it works on the element names for instance, but if I replace * by processing-instruction to use it on the processing-instructions, I get nothing.

Probably your starting code is wrong. The Muenchian method works nicely:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:eek:utput method="text"/>

<xsl:key name="kPI" match="processing-instruction"
use="name"/>

<xsl:template match="/">
<xsl:for-each
select="//processing-instruction
[generate-id
=
generate-id(key('kPI',
name)[1]
)
]">
<xsl:value-of select="concat(name, '&#xA;')"/>

</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

when applied on this source.xml:

<t>
<?xxx PI1?>
<a>
<?xxx PI2?>
<b>
<?yyy PI3?>
<c/>
</b>
<?zzz PI4?>
</a>
</t>

the wanted result is produced:

xxx
yyy
zzz

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 

Vincent Lefevre

Usenet Archive
Joined
Aug 11, 2002
Messages
60
Reaction score
0
Dimitre Novatchev said:
Probably your starting code is wrong.

I'm quite sure it was correct.
The Muenchian method works nicely:
[...]

I've tried your example, and I get nothing with xsltproc (with the tests I've done yesterday, it seems that PIs are not matched in xsl:key). I'm going to fill a bug report.
 

Dimitre Novatchev

Usenet Archive
Joined
Nov 7, 2000
Messages
737
Reaction score
0
Yes, it is a bug -- I get "Transformation failed" with no more specific error message. My libXslt is at least 3 months old.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

Vincent Lefevre said:
Dimitre Novatchev said:
Probably your starting code is wrong.

I'm quite sure it was correct.
The Muenchian method works nicely:
[...]

I've tried your example, and I get nothing with xsltproc (with the tests I've done yesterday, it seems that PIs are not matched in xsl:key). I'm going to fill a bug report.
 

Peter Flynn

Usenet Archive
Joined
Jan 2, 2000
Messages
1,813
Reaction score
0
Vincent said:
How can I get the list of the processing-instruction names in a file?

$ tr '\012\074' '\040\012' <foo.xml | grep '^?' | awk '{print substr($1,2)}'

///Peter
 

Vincent Lefevre

Usenet Archive
Joined
Aug 11, 2002
Messages
60
Reaction score
0
I forgot to say that I needed that in XSLT (but then, the problem was a bug in libxslt).
$ tr '\012\074' '\040\012' <foo.xml | grep '^?' | awk '{print substr($1,2)}'

which doesn't work anyway.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top