[SlugBug] a perl/xslt question. potentially inappropriate.
Mike Dewar
m.dewar at shef.ac.uk
Sun Apr 17 22:57:20 BST 2005
That's bloody great, that is. With your help I've managed to write the
stylesheet and it seems to work with quite a variety of different
pages... all i have to do now is recursively jump about directories,
converting xml to wiki and populating the wiki's MySQL database! No
problem!
Something tells me the job's just starting.
Cheers,
Mike D
Chris J wrote:
>And Lo! The Great Prophet Mike Dewar uttered these words of wisdom:
>
>
>>That's great! I was making things harder than they needed to be, and i
>>didn't realise you could apply a template that you hadn't created... I
>>suppose if you don't specify a template it just gives you the text in
>>the tag?
>>
>>
>
>Essentially yes. The actual rule basically says:
> - when you apply templates to an element, process its child
> elements
> - when you apply templates to a text node, give its value
>
>...so in essence, you're just getting the textual information.
>
>
>
>>Would making it a bit more human-readable be a huge problem? The reason
>>I ask is that the wiki should be human-editable once it's up... this
>>mucking about with xml should just be to populate the wiki to begin
>>with. Everything after this should remain in the wiki. Having readable
>>text will make it easier for people who aren't used to editing things
>>like this to go ahead and edit the wiki....
>>
>>
>
>It might depend on the XSLT implementation, but some dirt simple poking
>about managed to churn out some more useable output:
>
><?xml version="1.0"?>
>
><xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
>
> <xsl:template match="/">
> <xsl:apply-templates />
> </xsl:template>
>
> <xsl:template match="P"><P><xsl:apply-templates /></P></xsl:template>
>
> <xsl:template match="VERB">'''<xsl:apply-templates />'''</xsl:template>
>
></xsl:transform>
>
>...notice I've essentially removed the newlines from the P and VERB
>templates. With sablotron, this gives:
>
><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>
>
>Copying text nodes can often be hit and miss; I've never quite got the
>whitespace to appear as I want it. It is possible to insert explicit
>newlines with <xsl:text>, but sometimes extra newlines can appear where you
>don't want them. More often than not it's a case of restructuring the XSLT
>to suppress the newlines, as above.
>
>Usually it's never a problem though as I'm using it to spit out HTML or XML
>for further machine processing, and not for human consumption... :-)
>
>Chris...
>
>
>
More information about the SlugBug
mailing list