Add links in a document

Discussion in 'XML' started by NiQuil, Jan 10, 2005.

  1. NiQuil

    NiQuil Guest

    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.
    NiQuil, Jan 10, 2005
    #1
    1. Advertising

  2. NiQuil

    Joris Gillis Guest

    Tempore 13:06:56, die Monday 10 January 2005 AD, hinc in foro {comp.text.xml} scripsit NiQuil <>:

    > 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-view.cgi?userid=38041)
    Vincit omnia simplicitas
    Keep it simple
    Joris Gillis, Jan 10, 2005
    #2
    1. Advertising

  3. NiQuil

    NiQuil Guest

    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!
    NiQuil, Jan 11, 2005
    #3
  4. NiQuil

    NiQuil Guest

    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!!

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    NiQuil, Jan 11, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gemmel
    Replies:
    0
    Views:
    304
    Gemmel
    Sep 10, 2004
  2. www.westerncartooncards.ca

    Exchange Links < Western Cartoon Cards > Exchange Links

    www.westerncartooncards.ca, Jul 12, 2004, in forum: HTML
    Replies:
    2
    Views:
    1,219
    Toby Inkster
    Jul 12, 2004
  3. Gemmel
    Replies:
    1
    Views:
    409
    Martin Honnen
    Sep 10, 2004
  4. Konrad Mathieu

    document.links["id"].href -> Browsersafe?

    Konrad Mathieu, Jul 17, 2003, in forum: Javascript
    Replies:
    2
    Views:
    215
  5. Garrett Smith
    Replies:
    14
    Views:
    298
    David Mark
    May 26, 2009
Loading...

Share This Page