[SlugBug] a perl/xslt question. potentially inappropriate.

Mike Dewar m.dewar at sheffield.ac.uk
Sat Apr 16 12:10:24 BST 2005


Hi all,

I'm slowly progressing with this xslt stuff. However, I'm totally 
stumped with this one thing that no end of O'Reilly browsing or google 
hunting seems to be helping me with. It's probably a case of not 
knowing the keywords. Anyway, Slugbug is the next port of call for me!

Here's the XML (from the Scilab Source)

<P>
     For a vector or a matrix <VERB>x</VERB>, <VERB>y=sum(x)</VERB>  
returns in the scalar <VERB>y</VERB> the sum of all the entries
     of <VERB>x</VERB>.</P>

and here's what i want it to look like for the wiki:

<P>
     For a vector or a matrix '''x''', '''y=sum(x)'''  returns in the 
scalar '''y''' the sum of all the entries
     of '''x'''.</P>

Can anyone help? I think the problem I'm having is that the VERB things 
are nested in the text of the P tags. I can only seem to get the all 
the text() elements of P then the text inside the VERB tags. I cant 
keep them nested...

Cheers,

Mike D

On 1 Apr 2005, at 09:43, Chris J wrote:

>
> [[ replies inline ]]
>
>> Context: I'm trying to set up a documentation wiki for an open-source
>> program called Scilab, which is a sort-of alternative to Matlab. I'm 
>> an
>> Engineering PhD student at the University. I'm doing this because...
>> ermm... I don't know why I'm doing this. It's not part of my studies.
>
> I vaugely remember scilab; looked at it once many many years ago...
>
> ...[deletia]...
>
>>
>> Problem (low-level): I'm using the Perl module XML::XSLT to try and do
>> the conversion and, to make sure everything's hunky-dory, I'm using 
>> the
>> XSLT stylesheet that already does the conversion between the XML and
>> Scilab's existing (and bad) HTML online help. Nothing's hunky-dory,
>> errors occur i think, within the module when I try and do the
>> transform. I can't make the thing work.
>>
>> Question 0: Is this an appropriate forum to discuss Perl and stuff 
>> like
>> this? If not, can anyone give me any pointers to an appropriate (and
>> local if poss) forum?
>
> It's been done before. I'm sure someone'll shout if it strays too much
> off topic :-)
>
>>
>> Question 1: Is my Potential Solution viable, or is there a better way?
>> For ages I was trying to do screen-scraping stuff and only recently
>> found out about XSLT. There is probably other solutions that I could 
>> be
>> using that I've not heard about.
>
> XSLT's fantastic for converting from XML to something else - XML, HTML 
> or
> plain text; I've used it widely for XML to XML/XHTML conversion both 
> at work
> and play, and I run a setlist database[1] purely on XSLT. It should be
> perfectly viable to use XSLT.
>
> What format are the WIKI entries in?
>
>
>> Question 2: Is there a different tool with which I can perform the
>> transform, either a perl module or some other thing that I can call
>> from within a perl script...?
>
> For [1], I use my own CGI[2] written on top of Sablotron[3] - I don't 
> know
> if there's a perl hook for it, but it does come with a standalone 
> parser,
> sabcmd, which you could call from Perl.  I've never used XML::XSLT, but
> if you've worked out how to perform a transform using that, I can't see
> why it is any better or worse than any other XSLT/Perl solution.
>
> IIRC, Sablotron is also the XSLT parser used by PHP. Technically it 
> shouldn't
> matter what parser is used though if the software authors have 
> implemented
> XSLT 1.0 correctly :-)
>
> There's also xmlgawk[4], i.e., Awk with extensions to parse XML. I've
> never used it, but intend to investigate it as it looks quite useful 
> for
> simple queries.
>
> Chris...
>
> [1] http://cej.nightwolf.org.uk/batfink/
> [2] http://cej.nightwolf.org.uk/linux/xslt-cgi.tar.gz
> [3] http://www.gingerall.com/charlie/ga/xml/p_sab.xml
> [4] http://home.vrweb.de/~juergen.kahrs/gawk/XML/
>
>
> -- 
> \ Chris Johnson           \
>  \ cej at nightwolf.org.uk    ~-----,
>   \ http://cej.nightwolf.org.uk/  ~-----------------------------------,
>    \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 
> \____



More information about the SlugBug mailing list