How to write a link into XML? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to write a link into XML?

_NeMo__NeMo_ Posts: 4Member
[b][red]This message was edited by Moderator at 2004-4-12 4:17:36[/red][/b][hr]
Hello, I am a newcomer to XML.

Here is my question:

I want to use a tag (like ) which will contain a link to a file.

The problem is when I write a statement, and I connect the xml file with an html table, this link doesn't appear.
All the other fields appear OK.

There is any way to write a link into XML?

Thank you in advance


Comments

  • lillulillu Posts: 308Member
    Hi,

    I am also a newcomer but I can give you a simple solution which I've been using for my purposes:

    link.xml

    <?xml version="1.0" encoding="ISO8859-1"?>
    <?xml-stylesheet type="text/xsl" href="link.xsl"?>

    Link 1
    Link 2
    Link 3


    link.xsl

    <?xml version="1.0" encoding="ISO8859-1"?>



















    As you can see, for simplicity, the xml tag definitions mimic the way of HTML, using for value="" for href="" and the text between Link 1 Link 1

    Three things going in the LINK iteration of the xsl file:

    1. at href="" place the value of VALUE from xml there
    3. go find the text nodes (anything written inside

    Hope this helped,

    Lillu


    : Hello, I am a newcomer to XML.
    :
    : Here is my question:
    :
    : I want to use a tag (like ) which will contain a link to a file.
    :
    : The problem is when I write a statement, and I connect the xml file with an html table, this link doesn't appear.
    : All the other fields appear OK.
    :
    : There is any way to write a link into XML?
    :
    : Thank you in advance
    :

  • _NeMo__NeMo_ Posts: 4Member
    Thank you for your quick reply..

    As a matter of fact your code works fine. But still I have some problems.

    My xml file is

    link.xml
    <?xml version="1.0" encoding="ISO8859-1"?>
    <?xml-stylesheet type="text/xsl" href="link.xsl"?>

    Suzie
    30sec
    Quality level 3
    130kbps

    Link 1



    and the xsl file is

    link.xsl
    <?xml version="1.0" encoding="ISO8859-1"?>



















    My collection
















    TitleDurationQualityBitrateLink




    With this file I input the data into a table.

    The problem is how I can combine this xsl with yours?
    <?xml version="1.0" encoding="ISO8859-1"?>




















    I have tried some combinations, but it seems that 2 xsls can;t work together...

    My scope is to have a table with the metadata of my videoclips and a link to each of them...

    Thank you SO MUCH for your help till now...


  • lillulillu Posts: 308Member
    Hi,

    Of course it doesn't work. You must tailor my snippet into yours taking carefully the node structure into consideration. My example was just to show how a link can work but when you embed it in yours, you have to adjust it to your elements.

    So, I changed your xml a bit as I didn't find a root node. I assume you want to list more than one video otherwise what's the point? So will hold all children.

    Another thing: It's not necessary to have when you only want to associate one link only with . If you had more than one link to the same video, that would be fine.

    link1.xml

    <?xml version="1.0" encoding="ISO8859-1"?>
    <?xml-stylesheet type="text/xsl" href="link1.xsl"?>


    Suzie
    30 sec
    Quality level 3
    130 kbps
    Link 3



    And now the XSL:

    <?xml version="1.0" encoding="ISO8859-1"?>


    My collection
















    Title Duration Quality Bitrate Link









    I explain now how the gets inserted as you are OK with the rest.

    So, when you finished with formatting you say, I want a hyperlink here.

    1. You create the html tag.
    2. You define an attribute to the
    tag by saying attribute name="href". So far you have this:
    4. Then you get the text from and put it after

    5. You close the
    tag.


    Hope this helped.

    Lillu






    : Thank you for your quick reply..
    :
    : As a matter of fact your code works fine. But still I have some problems.
    :
    : My xml file is
    :
    : link.xml
    : <?xml version="1.0" encoding="ISO8859-1"?>
    : <?xml-stylesheet type="text/xsl" href="link.xsl"?>
    :
    : Suzie
    : 30sec
    : Quality level 3
    : 130kbps
    :
    : Link 1
    :
    :
    :
    : and the xsl file is
    :
    : link.xsl
    : <?xml version="1.0" encoding="ISO8859-1"?>
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :

    :

    :
    :
    :
    :
    :
    :

    My collection

    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    TitleDurationQualityBitrateLink
    :
    :
    :
    :
    :
    : With this file I input the data into a table.
    :
    : The problem is how I can combine this xsl with yours?
    : <?xml version="1.0" encoding="ISO8859-1"?>
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :

    :

    :
    :
    :
    :
    : I have tried some combinations, but it seems that 2 xsls can;t work together...
    :
    : My scope is to have a table with the metadata of my videoclips and a link to each of them...
    :
    : Thank you SO MUCH for your help till now...
    :
    :
    :

  • infidelinfidel Posts: 2,900Member
    : link1.xml
    [code]
    <?xml version="1.0" encoding="ISO8859-1"?>
    <?xml-stylesheet type="text/xsl" href="link1.xsl"?>


    Suzie
    30 sec
    Quality level 3
    130 kbps
    Link 3


    [/code]

    : And now the XSL:
    [code]
    <?xml version="1.0" encoding="ISO8859-1"?>




    My collection










    Title Duration Quality Bitrate Link






















    [/code]

    No sense in having the VIDEOS/VIDEO collection if you're not going to make templates to take advantage of it. I'm sure it was just an oversight in this trivial example.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • lillulillu Posts: 308Member
    Thanks infidel, just realized...

    Lillu

    : : link1.xml
    : [code]
    : <?xml version="1.0" encoding="ISO8859-1"?>
    : <?xml-stylesheet type="text/xsl" href="link1.xsl"?>
    :
    :
    : Suzie
    : 30 sec
    : Quality level 3
    : 130 kbps
    : Link 3
    :
    :
    : [/code]
    :
    : : And now the XSL:
    : [code]
    : <?xml version="1.0" encoding="ISO8859-1"?>
    :
    :
    :
    :
    :
    :

    My collection

    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    Title Duration Quality Bitrate Link
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :

    :
    :
    :
    :
    :
    : [/code]
    :
    : No sense in having the VIDEOS/VIDEO collection if you're not going to make templates to take advantage of it. I'm sure it was just an oversight in this trivial example.
    :
    :
    : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]
    :
    :

  • _NeMo__NeMo_ Posts: 4Member
    [b][red]This message was edited by Moderator at 2004-4-12 4:29:27[/red][/b][hr]
    Thank you very much for your replies!!

    I also come out with some xsl code:

    link1.xml

    <?xml version="1.0" encoding="ISO8859-1"?>
    <?xml-stylesheet type="text/xsl" href="link1.xsl"?>


    Suzie
    30 sec
    Quality level 3
    130 kbps
    Link 3


    REX
    130 sec
    Quality level 5
    500 kbps
    Link 3




    And now the XSL:

    <?xml version="1.0" encoding="ISO8859-1"?>
















    TITLE:



    DURATION:



    QUALITY:



    BITRATE:


    =======================================================>





    Now if I want to filter the data that this xsl depicts, can I use the
    statement?

    I have tried it without encouraging results.

    Thanks again...



  • lillulillu Posts: 308Member
    Hi,

    I corrected link1.xsl as you could not add more than one tags in your xml.

    Here's videos.xml

    <?xml version="1.0" encoding="ISO8859-1"?>
    <?xml-stylesheet type="text/xsl" href="videos.xsl"?>


    Suzie
    30 sec
    Quality level 3
    130 kbps
    Link 1


    REX
    130 sec
    Quality level 5
    500 kbps
    Link 2


    Another Day in Paradise
    280 sec
    Quality level 5
    1029 kbps
    Link 3



    I changed the text inside DURATION and BITRATE. It's good practice not to use mixed data type within one tag. It makes sorting/filtering a lot easier.

    videos.xsl

    <?xml version="1.0" encoding="ISO8859-1"?>



    My collection


















    Title Duration Quality Bitrate Link










    : Now if I want to filter the data that this xsl depicts, can I use the
    : statement?

    Well, if you want to filter certain elements that match some criteria, you use
    For-each is for looping through all the elements.

    I actually made a filter to your videos.xml and xsl.

    The xml file remains the same, you just change the second line to this:

    <?xml-stylesheet type="text/xsl" href="videos_filter.xsl"?> (where you call xsl stylesheet to be applied to your xml.

    videos_filter.xsl

    2 tiny lines changed between the for-each tag.

    <?xml version="1.0" encoding="ISO8859-1"?>



    My collection




















    Title Duration (sec) Quality Bitrate (kbps) Link










    Well, I'm very new to xml/xsl as well, but I help myself to these easy tutorials here: http://www.w3schools.com/

    Good luck,

    Lillu

    :
    : I have tried it without encouraging results.
    :
    : Thanks again...
    :
    :

  • _NeMo__NeMo_ Posts: 4Member
    Thank you.... you are a lifesaver...


    : Hi,
    :
    : I corrected link1.xsl as you could not add more than one tags in your xml.
    :
    : Here's videos.xml
    :
    : <?xml version="1.0" encoding="ISO8859-1"?>
    : <?xml-stylesheet type="text/xsl" href="videos.xsl"?>
    :
    :
    : Suzie
    : 30 sec
    : Quality level 3
    : 130 kbps
    : Link 1
    :
    :
    : REX
    : 130 sec
    : Quality level 5
    : 500 kbps
    : Link 2
    :
    :
    : Another Day in Paradise
    : 280 sec
    : Quality level 5
    : 1029 kbps
    : Link 3
    :
    :
    :
    : I changed the text inside DURATION and BITRATE. It's good practice not to use mixed data type within one tag. It makes sorting/filtering a lot easier.
    :
    : videos.xsl
    :
    : <?xml version="1.0" encoding="ISO8859-1"?>
    :
    :
    :
    :
    :

    My collection

    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    Title Duration Quality Bitrate Link

    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : : Now if I want to filter the data that this xsl depicts, can I use the
    : : statement?
    :
    : Well, if you want to filter certain elements that match some criteria, you use
    : For-each is for looping through all the elements.
    :
    : I actually made a filter to your videos.xml and xsl.
    :
    : The xml file remains the same, you just change the second line to this:
    :
    : <?xml-stylesheet type="text/xsl" href="videos_filter.xsl"?> (where you call xsl stylesheet to be applied to your xml.
    :
    : videos_filter.xsl
    :
    : 2 tiny lines changed between the for-each tag.
    :
    : <?xml version="1.0" encoding="ISO8859-1"?>
    :
    :
    :
    :
    :

    My collection

    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    Title Duration (sec) Quality Bitrate (kbps) Link

    :
    :
    :
    :
    :
    :
    :
    :
    :
    :
    : Well, I'm very new to xml/xsl as well, but I help myself to these easy tutorials here: http://www.w3schools.com/
    :
    : Good luck,
    :
    : Lillu
    :
    : :
    : : I have tried it without encouraging results.
    : :
    : : Thanks again...
    : :
    : :
    :
    :

Sign In or Register to comment.