Advice on including hyperlinks in XML pages
I'm looking for a way of doing an apparently simple thing - hyperlink arbitrary phrases. Say I have something like
<para>here is some text containg a link to a different section of this website</para>
And I want "a link" to be a link (I know that's not good link text; it's just an example!). I dont really want to go:
<para>here is some text containing <url href="page.html">a link</url> to a different section of this website</para>
But it's not what I want - I wouldn't be able to retrieve the whole paragraph of text using <xsl:value-of/>; in fact I'm unsure how to parse that at all - given that there may be 0 or more <url/> elements inside each <para> ... how would I be able to end up with anything other than bits of plain text followed by each of the links? Is it possible to use <xsl:for-each/> to iterate through nodes recursively and then compile the results at the end ..?
But anyway, it just feels wrong; like i'm forcing metadata to be inside a data node. So my alternative idea was something like
<para url="page.html" text="a link"> ... </para>
which would be easy to parse into linked text, by getting the XSL to generate PHP, and then preg_replace the text which matches attribute values; and it reflects the nature of the link data. But it's not extensible ... not without "url1" "url2" etc ... or is there an array syntax for attributes ?
Long question I know ... I'd appreciate any suggestions or comments.
Last edited by brothercake; 01-23-2003 at 02:44 AM..