xsl-list
[Top] [All Lists]

Re: [xsl] xsl:choose and xsl:when

2007-08-29 08:47:46


It's always useful to see some sample input.... so
guessing that your
XML looks like this:

My bad.... Here is my XML data:

If you can still change the source, I have some suggestions for you:

1. remove the DOCTYPE, it does nothing this way

2. add an encoding attribute (otherwise it is assumed UTF-8, is that what it
really is?

3. use small caps for readability (but that's of course a personal opinion,
but to me, PhoneBook, or phone-book is more readable than PHONEBOOK).

4. remove LISTING, it does not seem to add any semantics

5. remove the surrounding whitespace

6. last but not least, most importantly, change your blocks so that each
listed person has its own block.


Together this would yield:

<?xml version="1.0" encoding="utf-8" ?>
<phone-book>
   <person>
      <first>Derek</first>
      <last>Smith</last>
   </person>
   <person>
      <first>Joseph</first>
      .... etc
</phone-book>


If changing the source is not an option, you would probably benefit a lot if
you process it in two passes, either using a micro pipe (XSLT 2.0, XSLT 1.0
with nodeset) or using two processes (XSLT 1.0), where your first pass would
optimize the badly formatted XML data.

Your second phase will then be much easier to maintain and you can focus on
the layout of your HTML instead of on the structure of your XML.

Cheers,
-- Abel Braaksma


<?xml version="1.0"?>
<!DOCTYPE PHONEBOOK>
<PHONEBOOK>
    <LISTING>
        <FIRST> Derek </FIRST>
        <LAST> Smith </LAST>
        <PHONE TYPE="CELL"> 614-757-2123 </PHONE>

        <FIRST> Joseph </FIRST>
....


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>