XSL question

Hi.

When I try to view my para.xml file with the XSL stylesheet with IE5, I get something like

1st title

2nd title

1st paragraph

2nd paragraph

This format is not desirable. What I want is to get the 1st title and then the 1st paragraph, and only after that the 2nd title and the 2nd paragraph.

Does any one know how to do this only by modifying the XSL stylesheet?

Here are the files:

-------------------
para.xml file:

<?xml-stylesheet type="text/xsl" href="para.xsl"?>

1st title
1st paragraph
2nd title
2nd paragraph


-------------------
para.xsl file:

<?xml version="1.0"?>















Comments

  • [b][red]This message was edited by iDaZe at 2003-2-5 7:38:8[/red][/b][hr]
    : Hi.
    :
    : When I try to view my para.xml file with the XSL stylesheet with IE5, I get something like
    :
    : 1st title
    :
    : 2nd title
    :
    : 1st paragraph
    :
    : 2nd paragraph
    :
    : This format is not desirable. What I want is to get the 1st title and then the 1st paragraph, and only after that the 2nd title and the 2nd paragraph.
    :
    : Does any one know how to do this only by modifying the XSL stylesheet?
    :
    : Here are the files:
    :
    : -------------------
    : para.xml file:
    :
    : <?xml-stylesheet type="text/xsl" href="para.xsl"?>
    :
    : 1st title
    : 1st paragraph
    : 2nd title
    : 2nd paragraph
    :
    :
    : -------------------
    : para.xsl file:
    :
    : <?xml version="1.0"?>
    :
    :
    :
    :
    :
    :
    :
    :

    :
    :
    :
    :

    :
    :
    :
    :
    :
    :
    :
    :

    I'm not really much of an expert on xml (only read a few tutorials and don't really use it much), but I don't think it can be done that easily.

    It would be easier if you edit both documents:
    [code]
    <?xml-stylesheet type="text/xsl" href="para.xsl"?>


    1st title
    1st paragraph


    2nd title
    2nd paragraph


    [/code]

    and

    [code]
    <?xml version="1.0"?>









    [/code]

  • [b][red]This message was edited by infidel at 2003-3-3 7:43:22[/red][/b][hr]
    [b][red]This message was edited by infidel at 2003-3-3 7:41:54[/red][/b][hr]
    : Hi.
    :
    : When I try to view my para.xml file with the XSL stylesheet with IE5, I get something like
    :
    : 1st title
    :
    : 2nd title
    :
    : 1st paragraph
    :
    : 2nd paragraph
    :
    : This format is not desirable. What I want is to get the 1st title and then the 1st paragraph, and only after that the 2nd title and the 2nd paragraph.
    :
    : Does any one know how to do this only by modifying the XSL stylesheet?
    :
    : Here are the files:
    :
    : -------------------
    : para.xml file:
    :
    : <?xml-stylesheet type="text/xsl" href="para.xsl"?>
    :
    : 1st title
    : 1st paragraph
    : 2nd title
    : 2nd paragraph
    :
    :
    : -------------------
    : para.xsl file:
    :
    : <?xml version="1.0"?>
    :
    :
    :
    :
    :
    :
    :
    :

    :
    :
    :
    :

    :
    :
    :
    :
    :
    :
    :

    The problem is the for-each loop. You would want to put the text for-each inside the ptitle for-each to get what you want, but that's kind of an ugly solution and doesn't utilize the flexibility and power of markup and templates. Try this:

    [code]
    <?xml version="1.0"?>




















    [/code]

    I haven't tried it out but it should work. Should also show you how powerful templates can be. You can think of templates as a kind of function call. It's better to write a lot of small functions that can handle any input rather than a single monolithic function which has to be modified any time the input is modified.


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





Sign In or Register to comment.

Howdy, Stranger!

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

Categories