Add links in a document

N

NiQuil

Hello people,

I am creating a portal which should be easy maintainable by
non-programmers.
Thus far people can easyly change the text, set it Bold Italic and
Underlined. Also i can set a footnote which will be displayed at the
bottom of the text.
The next feature i would like to create involves creating a link.

--->I want to be able to insert a link in a piece of tekst.<---

I am very new to xml (started yesterday) and I hope someone could give
me some directions in this matter.

This is what I have thus-far:
-------The DTD--------------------------------------------------
<!ENTITY % paratext " #PCDATA | bold | italic | underline | footnote">

<!ELEMENT page (message*)>
<!ELEMENT message (header, title, bodyText, footer, numbering)>

<!ELEMENT header (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT bodyNumber (#PCDATA)>
<!ELEMENT bodyText (paragraph*)>
<!ELEMENT paragraph (&paratext;)* >
<!ELEMENT footnote (&paratext;)*>
<!ELEMENT footer (#PCDATA)>
<!ELEMENT numbering (#PCDATA)>
------------------------------------------------------------------

--------The xslt--------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/page">
<html>
<body>
<table border="1" width="100%">
<tr>
<td>
<xsl:apply-templates select="message" />
</td>
</tr>
</table>
</body>
</html>
</xsl:template>

<xsl:template match="message">
<table border="1" bordercolor="#9acd32" width="100%">
<tr>
<td colspan="2">
<h6>
<xsl:value-of select="header" />
</h6>
</td>
</tr>
<tr>
<td colspan="2">
<h2>
<xsl:value-of select="title" />
</h2>
</td>
</tr>
<tr>
<td>
<xsl:value-of select="bodyNumber" />
</td>
<td>
<xsl:apply-templates select="bodyText" />
</td>
</tr>
<tr>
<td colspan="2">
<xsl:value-of select="footer" />
</td>
</tr>
</table><br/>
</xsl:template>

<xsl:template match="bodyText">
<table border="1" bordercolor="black" align="center" width="100%">
<tr>
<td><xsl:apply-templates select="paragraph"/> </td>
</tr>
</table>
</xsl:template>

<xsl:template match="paragraph">
<p><xsl:apply-templates /></p>
<xsl:for-each select="footnote">
<sup><xsl:number level="any" count="footnote" from="paragraph"
format="1"/></sup> <xsl:value-of select="." /><br />
</xsl:for-each>
</xsl:template>

<xsl:template match="footnote">
<sup><xsl:number level="any" count="footnote" from="paragraph"
format="1"/></sup>
</xsl:template>

<xsl:template match="bold">
<b><xsl:apply-templates /> </b>
</xsl:template>

<xsl:template match="underline">
<u><xsl:apply-templates /> </u>
</xsl:template>

<xsl:template match="italic">
<i><xsl:apply-templates /> </i>
</xsl:template>


</xsl:stylesheet>
---------------------------------------------------------------


-------XML-File------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--<!DOCTYPE GeneralText_1 SYSTEM "GeneralText_1.dtd"> -->
<?xml-stylesheet type="text/xsl" href="GeneralText_1.xslt"?>

<page>
<message>
<header>xml document editor</header>
<title>Welcome</title>
<bodyNumber>Punt 1</bodyNumber>
<bodyText>
<paragraph>text <bold>bold text</bold> more text<italic>Italic
text</italic> more text<underline>underlined text</underline>more
text<footnote>an added footnote</footnote>.</paragraph>
</bodyText>
<footer>Versie 0.1</footer>
<numbering>1</numbering>
</message>
----------------------------------------------------------------------------



Thank You in advance for your help.

If you feel i have put this question in the wrong newsgroup please
state so. (I am also new to newsgroups)

Greetz Wilbert.
 
J

Joris Gillis

Tempore 13:06:56 said:
The next feature i would like to create involves creating a link.
Hi,

You'd have to invent a new element and attributes and specify it in the DTD.

Here's an example:

<page>
<message>
<header>xml document editor</header>
<title>Welcome</title>
<bodyNumber>Punt 1</bodyNumber>
<bodyText>
<paragraph>text <bold>bold text</bold> more text<italic>Italic
text</italic> more text<underline>underlined text</underline>more
text<footnote>an added footnote</footnote>.</paragraph>
<paragraph><link location="http://www.w3.org/" info="W3C">The <bold>place</bold> to be</link></paragraph>
</bodyText>
<footer>Versie 0.1</footer>
<numbering>1</numbering>
</message>
</page>

An this would be an according template that can be added to the stylesheet:

<xsl:template match="link">
<a href="{@location}" title="{@info}"><xsl:apply-templates /> </a>
</xsl:template>



(Not related to the question, but you could consider making a table free-design)


regards,
 
N

NiQuil

Thank you for the reply, I found a way myself aswell, though it differs
from yours. Could you (anyone) tell me which way is best, and why?

xml:

<link value="link2.htm">Link 2</link>

xslt:

<xsl:template match="link">
<xsl:element name="a"><!--<a>--><xsl:attribute
name="href"><!--href="--><xsl:value-of select="@value"
/></xsl:attribute><!--eenurl--><xsl:value-of select="@value"
/><!--eenlinktekst--></xsl:element><!--</a>-->
</xsl:template>
 
N

NiQuil

Hi here niQuil again.

i have foud out that There is (going to be a full) standard for using
links called XLINK.
I don't know how it works yet but I'll try and figure it out.

The difference between our ways of adding a link is clear to me now,
it's just a notation difference.

When I find out how xlink works I will put an example here so others
might benifit from this thread aswell.

Afcourse, feel free to add one yourself, this would save me the work
from findin out myself ;-)

K, I'm off! tnx Again.

~~~~(¯`·._(.......NiQuil Of The iMaGiCa.......)_.·´¯)~~~~
*´¨) ~(...........My GOD i am new to xml..........)~~~~
¸.·´¸.·´) ¸.·->.: [N] :.: :.: [Q] :.: :.: :.: [l] :.
(¸.·´ (¸.·´ So much to learn, got to love it!!
 

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
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top