[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XML + XSL links (beguinner)

Posted on 2006-04-17
11
Medium Priority
?
311 Views
Last Modified: 2010-04-17
hi all
 
I'll try to explain you what i have
 in my XML file i have this:
 
Code :

    * <book>
    *   <content>
    *     <paragraphe>lorem ipsum.......</paragraphe>
    *     <paragraphe>dolor sit amet ....</paragraphe>
    *     <paragraphe>consectetuer adipiscing <link url="http://www.google.com">google</lien></paragraphe>
    *   </content>
    * </book>


 
in my stylesheet i have
 
Code :
    *.............
    * <xsl:template match="/">
    * <head>
    * <title>book</title>
    * </head>
    *
    * <body>
    *     <xsl:apply-templates/>  
    * </body>
    * </html>
    * </xsl:template>
    *
    * <xsl:template name="paragraphe">
    *         <p> <xsl:value-of select="."/></p>
    *         <xsl:apply-templates/>    
    * </xsl:template>
    *
    * <xsl:template match="//link">
    *    
    *     <a href="{@url}">
    *     <xsl:value-of select="." />
    *     </a>
    *    
    * </xsl:template>
    *
    * </xsl:stylesheet>


 
 so what i want, is that each paragraph shows independant using <p>

And, and this is the most important, whenever it finds a LINK ELEMENT, child of paragraphe or no, it must display it's content as a valid link .. for example here it's google(google must be underlined and clickable)
 
the stylesheet that i'm having is not working correctly, so could you plz help me with that
(i'm still a beguinner with XML)

Thx a lot in advance
0
Comment
Question by:jalalmegadeth
  • 4
  • 3
  • 2
  • +1
11 Comments
 
LVL 10

Expert Comment

by:Eduard Ghergu
ID: 16467551
Hello!

First of all change:
paragraphe>consectetuer adipiscing <link url="http://www.google.com">google</lien></paragraphe>
to
paragraphe>consectetuer adipiscing <link url="http://www.google.com">google</link></paragraphe>

Please, let me know if it is working now...
0
 
LVL 11

Expert Comment

by:WelkinMaze
ID: 16467552
Hi,
Wouldn't </lien> be </link>?
0
 
LVL 16

Expert Comment

by:suprapto45
ID: 16467555
Will this help?

http://www.devx.com/tips/Tip/21599

David
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:suprapto45
ID: 16467566
>>"Wouldn't </lien> be </link>?"
That is good point. I never saw that.

Points to both ghergu and WelkinMaze if it works !!! I do not deserve points here ;)

David
0
 
LVL 5

Author Comment

by:jalalmegadeth
ID: 16467727
yes yes, i'm sorry

in fact it's LINK instead of lien
even in the XML file it's link :))

i'm sorry about that


even with that, it'S not working

any help? :)
0
 
LVL 5

Author Comment

by:jalalmegadeth
ID: 16467748
in fact i have to correct the codes that i posted earlier ...

XML file :
Code :

    * <book>
    *   <content>
    *     <paragraphe>lorem ipsum.......</paragraphe>
    *     <paragraphe>dolor sit amet ....</paragraphe>
    *     <paragraphe>consectetuer adipiscing <link url="http://www.google.com">google</link></paragraphe>
    *   </content>
    * </book>


 
in my stylesheet i have
 
Code :
    *.............
    * <xsl:template match="/">
    * <head>
    * <title>book</title>
    * </head>
    *
    * <body>
    *     <xsl:apply-templates/>  
    * </body>
    * </html>
    * </xsl:template>
    *
    * <xsl:template match="paragraphe">
    *         <p> <xsl:value-of select="."/></p>
    *         <xsl:apply-templates/>    
    * </xsl:template>
    *
    * <xsl:template match="//link">
    *    
    *     <a href="{@url}">
    *     <xsl:value-of select="." />
    *     </a>
    *    
    * </xsl:template>
    *
    * </xsl:stylesheet>



This is what i have in fact

and what it displays, is the text in paragraphs, but no links are displayed

like this :

lorem ipsum.......
dolor sit amet ....
consectetuer adipiscing google(no link)

help plz :))
0
 
LVL 10

Expert Comment

by:Eduard Ghergu
ID: 16467803
Hello!

Please, try to change:
...
    * <xsl:template match="//link">
    *    
    *     <a href="{@url}">
    *     <xsl:value-of select="." />
    *     </a>
    *    
    * </xsl:template>
...
with
    * <xsl:template match="//link">
    *    
    *     <a href="{@url}">
    *     <xsl:value-of select="." />
    *     </a>
    *    <xsl:apply-templates/>
    * </xsl:template>
0
 
LVL 11

Accepted Solution

by:
WelkinMaze earned 1000 total points
ID: 16467831
Try to change:

    * <xsl:template match="paragraphe">
    *         <p> <xsl:value-of select="."/></p>
    *         <xsl:apply-templates/>    
    * </xsl:template>

with this one:

    * <xsl:template match="paragraphe">
    *         <p> <xsl:apply-templates/></p>
    * </xsl:template>

0
 
LVL 5

Author Comment

by:jalalmegadeth
ID: 16468044
>>>>>>>>>>>>>@gherghu

when i make the changes you told me here's what i get

lorem ipsum.......
lorem ipsum.......

dolor sit amet ....
dolor sit amet ....

consectetuer adipiscing google(no link)
consectetuer adipiscing google(link)google(no link)


>>>>>>>>>>@WelkinMaze
when i make the changes you told me here's what i get

lorem ipsum.......
lorem ipsum.......

dolor sit amet ....
dolor sit amet ....

consectetuer adipiscing google(link)
consectetuer adipiscing google(link)




as you see guys, the problem that i'm having now, is that it displays everything twice ?
what can i do to resolve that ?
0
 
LVL 11

Expert Comment

by:WelkinMaze
ID: 16468152
Hm, can you try the one below again as it is.
I've tried it and it works fine here.
I have a suspicion that you've tried my suggestion in combination with the gherghu's one.

    *.............
    * <xsl:template match="/">
    * <head>
    * <title>book</title>
    * </head>
    *
    * <body>
    *     <xsl:apply-templates/>  
    * </body>
    * </html>
    * </xsl:template>
    *
    * <xsl:template match="paragraphe">
    *         <p> <xsl:apply-templates/></p>
    * </xsl:template>
    *
    * <xsl:template match="//link">
    *    
    *     <a href="{@url}">
    *     <xsl:value-of select="." />
    *     </a>
    *    
    * </xsl:template>
    *
    * </xsl:stylesheet>
0
 
LVL 5

Author Comment

by:jalalmegadeth
ID: 16472696
Ohhhhhh yes !!! yes WelkinMaze you're right

It works just fine !! thanks a lot !! :)
in fact i don't even know what was wrong !
thx a lot again, you saved me ! :)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn different types of Android Layout and some basics of an Android App.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question