Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Add links in a document

Reply
Thread Tools

Add links in a document

 
 
NiQuil
Guest
Posts: n/a
 
      01-10-2005
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"
xmlnssl="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.
 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      01-10-2005
Tempore 13:06:56, die Monday 10 January 2005 AD, hinc in foro {comp.text.xml} scripsit NiQuil <(E-Mail Removed)>:

> 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,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Vincit omnia simplicitas
Keep it simple
 
Reply With Quote
 
 
 
 
NiQuil
Guest
Posts: n/a
 
      01-11-2005


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>



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
NiQuil
Guest
Posts: n/a
 
      01-11-2005
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] :.: [i] :.: [Q] :.: [u] :.: [i] :.: [l] :.
(. (. So much to learn, got to love it!!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update to FAQ - Relative URLs for In-page Links and Links to Notes Garrett Smith Javascript 14 05-26-2009 04:50 PM
FF Crashes on Links within Links Puma Firefox 10 02-17-2009 07:12 PM
Make A Shorter Link - no new links accepted, old links still work. why? Computer Support 7 01-02-2007 09:45 PM
Site Links and Physical WAN Links =?Utf-8?B?RW5mb1BhdWw=?= MCSE 2 03-22-2005 09:23 AM
Exchange Links < Western Cartoon Cards > Exchange Links www.westerncartooncards.ca HTML 2 07-12-2004 07:59 PM



Advertisments