link

link

Post by EniGMist » Fri, 04 Jul 2003 20:13:07



hi. I am new on this NG. Compliments for all :): I am newbie with XML. I
have a question:

I have a XML document:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="xsl/v1.xsl" ?>
    <curriculum>
         <lavori>
            <nome>CapriGo</nome>
            <url>http://www.mysite.com</url>
            <descrizione>Description</descrizione>
            <tecnologia>PHP, HTML, XML</tecnologia>
         </lavori>
    </curriculum>

this is xsl/v1.xsl:

<?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="curriculum">
<html>
<head>
<title>Curriculum vitae by EniGMistA</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="language" content="italian" />
<meta name="author" content="EniGMistA" />
<meta name="copyright" content="EniGMistA" />
<meta name="description" content="EniGMistA's curriculum vitae" />
<meta name="keywords" content="curriculum, curricula" />
<meta name="distribution" content="public" />

/>
<meta name="MSSmartTagsPreventParsing" content="TRUE" />

<meta name="robots" content="all" />
<meta name="Generator" content="notepad" />
<meta name="revisit-after" content="30 days" />

<link rel="stylesheet" title="Light" type="text/css" media="screen"
href="css/screen/v1/light.css" />

</head>
     <body>
        <div id="testa">
            <ul type="square">
                <xsl:for-each select="lavori">
                <xsl:sort select="nome"/>
                    <li>
                        <em><xsl:value-of select="nome" /></em><br />
                        URL:
                        <xsl:choose>
                        <xsl:when test="url=''">Non disponibile</xsl:when>
                        <xsl:otherwise><xsl:value-of select="url"
/></xsl:otherwise>
                        </xsl:choose>
                        <br />
                        Descrizione: <xsl:value-of select="descrizione"
/><br />
                        Tecnologia: <xsl:value-of select="tecnologia" />
                    </li>
                </xsl:for-each>
            </ul>
        </div>
     </body>
</html>
</xsl:template>
</xsl:stylesheet>

How can i display <url> as hyperlink? tnx

--
   .__.
  NN""4N
  N    4)
      .N)    EniGMistA
    (NF`

    _.
   (NN

 
 
 

link

Post by Christophe Jacque » Fri, 04 Jul 2003 20:33:02


Hi,

Quote:> How can i display <url> as hyperlink? tnx

I personaly use a template like this:

<xsl:template match="url">
     <a href="{text()}">
       <xsl:value-of select="text()" />
     </a>
</xsl:template>

Regards.

--
Christophe Jacquet
http://jacquetc.free.fr/

 
 
 

link

Post by EniGMist » Fri, 04 Jul 2003 20:56:22


in my code?
where i must put it?

--
   .__.
  NN""4N
  N    4)
      .N)    EniGMistA
    (NF`

    _.
   (NN

 
 
 

link

Post by Christophe Jacque » Fri, 04 Jul 2003 21:43:38



> in my code?
> where i must put it?

You have to do two things:
  - insert my template for "url" as a sibling of your template for
"curriculum" (you will have two templates in your stylesheet),
  - replace your ' <xsl:value-of select="url" /> ' with '
<xsl:apply-templates select="url" /> ' in order to call the appropriate
template.

To make things clear, here is your modified XSL file:

<?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="curriculum">
   <html>
     <head> [...] </head>
     <body>
       <div id="testa">
         <ul type="square">
           <xsl:for-each select="lavori">
             <xsl:sort select="nome"/>
             <li>
               <em><xsl:value-of select="nome" /></em><br />
               URL:
               <xsl:choose>
                 <xsl:when test="url=''">Non disponibile</xsl:when>
                 <xsl:otherwise>
                   <xsl:apply-templates select="url" />
                 </xsl:otherwise>
               </xsl:choose>
               <br />
               Descrizione: <xsl:value-of select="descrizione" /><br />
               Tecnologia: <xsl:value-of select="tecnologia" />
             </li>
           </xsl:for-each>
         </ul>
       </div>
     </body>
   </html>
</xsl:template>

<xsl:template match="url">
     <a href="{text()}">
       <xsl:value-of select="text()" />
     </a>
</xsl:template>

</xsl:stylesheet>

Instead of creating a template for "url", it must be possible to put the
code directly into the main template, but I think it is better to build
modular stylesheets.

--
Christophe Jacquet
http://jacquetc.free.fr/

 
 
 

link

Post by EniGMist » Fri, 04 Jul 2003 22:03:26


tnx a lot. Now i have understand the templates :))
text() is a function?

--
   .__.
  NN""4N
  N    4)
      .N)    EniGMistA
    (NF`

    _.
   (NN

 
 
 

link

Post by Christophe Jacque » Sun, 06 Jul 2003 04:11:34



> text() is a function?

Not exactly: it is a "location step" that selects all text-node
children of the current node.

--
Christophe Jacquet
http://jacquetc.free.fr/

 
 
 

1. Dynamically creating link

I am creating a link to a file in HTML in the following manor.
This works when I use pyana a python Xlan object to generate the html.

When I use Mozilla to do the transform it does not rendor the link.

It seem likley there is a better way.
I saw som posts with {} brackets and <xsl:attribute name="href">
but am still missing some how to put it all together.

This sort of works MM_NAME contains first part of path.
Rest of path completed it looks like this.
<a href="file://hanover/mmlogs/WSTG12WB200306">WSTG12WB</a>

<xsl:text disable-output-escaping="yes"><a href="file://</xsl:text>
<xsl:value-of select="MM_NAME" />
<xsl:text disable-output-escaping="yes">/mmlogs/</xsl:text>
<xsl:value-of select="TOOL_NAME" />
<xsl:text disable-output-escaping="yes">200306"></xsl:text>

2. NR/2 v 1.09 & RC=441 error?

3. Linking Multiple XML files with one XSL file

4. extaneous character in printed output

5. XML-SVG-XLinks linking

6. FS or trade: Newton Keyboard

7. Problem <fo:basic-link> sets linkable area approx 10mm too high

8. Does decimation enlarge the effective sample size. If so how is the ratio calculated?

9. Xerces linking error LNK2001: unresolved external symbol... using VC++ 6.0

10. includes and link problems in xerces parser

11. E-mail link in XML data island in HTML doc - how to . . .

12. add a xsl link to xml file from php

13. Link