SitePoint Sponsor

User Tag List

Page 4 of 4 FirstFirst 1234
Results 76 to 93 of 93

Thread: Xsl Xslt

  1. #76
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One thing that I have noticed in due course, is that a lot of people who design an XSL stylesheet, have one XML tag to be depicted as one xHTML tag once transformed. So, what happens is that for example, they have 6 or so tags just to generate a single TABLE row yes?

    What I tend to do on the other hand, is just have the one XML tag to depict a single TABLE row, and leave it to the stylesheet it's self, which is it's job at the end of the day, to generate the complete TABLE row.

    I don't think the number of lines is as much a factor, as there are the number of templates to be matched, when compared. As, the number of templates increases, as does the amount of machine cycles, required to do the matching against the XML document.

    In my view, reducing the amount of XML tags (which btw, only have to describe data, and not it's structure), you reduce the load, as I see it. On the point of XML as a container for data, and not it's structure, this is why I only use the one XML tag, and not half a dozen, as in what I said in my first paragraph.

    Hope this makes some sense at least

  2. #77
    SitePoint Guru momos's Avatar
    Join Date
    Apr 2004
    Location
    Belgium
    Posts
    919
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand correctly, you put all your data in the attributes of the xml-tag?

    (I actually mix, depending on the use)

  3. #78
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand correctly, you put all your data in the attributes of the xml-tag?
    If that's the case it is very wrong. In my oppinion attributes should only be used for IDs, ID refs and for lists of well known values. Because this way, the schema is more flexible, and I don't give a damn that I increase processor cycles, because it is not a very big difference.

    For example:
    Code:
    <event runat="client" when="onvalid">
       <callback name="ExecOnValid">
            <parameter>12</parameter>
            <parameter>This element is valid</parameter>
       </callback>
    </event>

  4. #79
    SitePoint Guru momos's Avatar
    Join Date
    Apr 2004
    Location
    Belgium
    Posts
    919
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't know...

    Look at this example:
    Code:
    <table>
        <row id="a" name="go" description="a game" price="10" sold="23" />
        <row id="b" name="go2" description="a game" price="10" sold="23" />
        <row id="c" name="go3" description="a game" price="10" sold="23" />
    </table>
    vs
    Code:
    <table>
        <row>
            <id>a</id> 
            <name>go</name>
            <description>a game</description> 
            <price>10</price>
            <sold>23</sold>
        </row>
        <row>
            <id>b</id> 
            <name>go2</name>
            <description>a game</description> 
            <price>10</price>
            <sold>23</sold>
        </row>
        <row>
            <id>c</id> 
            <name>go3</name>
            <description>a game</description> 
            <price>10</price>
            <sold>23</sold>
        </row>
    </table>
    In the first way you get a smaller xml-file, I think it all depends from case to case...

  5. #80
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, it depends from case to case, but with attributes you cannot add more complex values to a field.

    Take for example:
    Code:
    <table>
        <row id="123" date="2005-02-03" />
    </table>
    
    versus
    
    <table>
        <row id="123">
            <date>
                <year>2005</year>
                <month>02</month>
                <day>03</day>
            </date>
        </row>
    </table>
    The problem with the first version is that my script knows that the date field is in Mysql format YYYY-MM-DD, but the XML should be more descriptive that that, because someone else reading the document might suspect that it is written like YYYY-DD-MM

  6. #81
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    it is very wrong
    There is no right or wrong when it comes to XML. Historically, XML presents us with two ways to encapsulate data, and each of them has some specific features. It's up to the developers to use those two ways as they need, using the one which is more suited to a particular situation.

    That being said, my personal approach is generally that the actual data goes into element values, while metadata, or data about data (like ids, names, certain types of dates etc), goes into attributes.

  7. #82
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I find it amazing how we always seem to derive back to the common questions on the topic of XSL. I have never seen any mention of security and XSL, actual implementations or approaches people take. Fundamentally why are people not taking advantage of seperating XML, XSL fragments out, and have thousand lines of a mixture of XSL and HTML? Do you honestly write a thousand lines of XSL or is this chunks & chunks of HTML embedded in XSL markup (Be realistic)?
    I really cannot understand why the topic of XSL has not progressed past the extreme basics. I have never seen any PHP XSL implementations worth their salt. If anyone has some implementations or could point me to any new projects I would love to look over them.

  8. #83
    SitePoint Guru
    Join Date
    Jul 2004
    Location
    Netherlands
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What about wysiwyg, if you load a piece of html out the database will the xls template be ruined if there is a funky syntax in it? Or can you filter this out some way?
    Go visit my site :-D you know you want to ;-)
    www.mech7.net

  9. #84
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I find it amazing how we always seem to derive back to the common questions on the topic of XSL. I have never seen any mention of security and XSL, actual implementations or approaches people take. Fundamentally why are people not taking advantage of seperating XML, XSL fragments out, and have thousand lines of a mixture of XSL and HTML? Do you honestly write a thousand lines of XSL or is this chunks & chunks of HTML embedded in XSL markup (Be realistic)?
    That's because people are still trying to figure out what is XSL good for. They are still trying to figure it out in other languages too. PHP does not have a decent template manager. How can it have a decent XSL approach when PHP4 does not have built in support.

    With PHP5 we are just discovering the technology.

  10. #85
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pixelsoul
    What about wysiwyg, if you load a piece of html out the database will the xls template be ruined if there is a funky syntax in it? Or can you filter this out some way?
    Technically, you should not be recording HTML in the database.

    But if you really want to, there is a PHP interface to a handy utility called
    HTML Tidy which can transform your html in valid xhtml.

  11. #86
    SitePoint Addict timvw's Avatar
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    354
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One of the pita's with php5 xsl is the fact that it's impossible to set the base_path...

    So i'm forced to pass the path to the xsl file, or preg_replace the xsl:include href tags..

  12. #87
    SitePoint Zealot cholmon's Avatar
    Join Date
    Mar 2004
    Location
    SC
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pixelsoul
    What about wysiwyg, if you load a piece of html out the database will the xls template be ruined if there is a funky syntax in it? Or can you filter this out some way?
    as long as the html fragment is valid xml, (and you know where it is located in your soon-to-be-transformed XML document) you can use the <xsl:copy/> element to make the XSLT processor pass it all through.

  13. #88
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a way to use xslt with php4 and php5 without having to change your code? Sorry if this seems like a dumb question, but I've never really messed with it. If there were a way to have it so it worked on 4 and 5, I'd probably be more inclined to check it out.

    - matt

  14. #89
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mwmitchell
    Is there a way to use xslt with php4 and php5 without having to change your code? Sorry if this seems like a dumb question, but I've never really messed with it. If there were a way to have it so it worked on 4 and 5, I'd probably be more inclined to check it out.

    - matt
    Well, the underlying XSLT is there. Running the XML data through an XSLT sheet is only a few lines of code,

    PHP Code:
    if (PHP_VERSION >= 5)
     {
         function 
    XSLT($xml$xsl)
         {
             
    $xslt = new XSLTProcessor();
             
    $xslt->importStyleSheet(DOMDocument::load($xsl));
             
    $out $xslt->transformToXML(DOMDocument::load($xml));
             return 
    $out;
         }
     }
     else
     {
         function 
    XSLT($xml$xsl)
         {
             
    $arguments = array(
                
    '/_xml' => file_get_contents($xml),
                
    '/_xsl' => file_get_contents($xsl)
             );
     
             
    $xsltproc xslt_create();
             
    $out xslt_process($xsltproc'arg:/_xml''arg:/_xsl'null$arguments);
             
    xslt_free($xsltproc);
     
             return 
    $out;
         }
     } 

  15. #90
    SitePoint Zealot ohnnyj's Avatar
    Join Date
    Jun 2003
    Location
    California
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cholmon
    Holy crap, what kind of page was it?

    Last year I had to do something similar. It was an employment application that ended up being 8 pages when printed out. the XSL for that thing was about 1200 lines long and it took about 10 seconds for the XHTML form itself to get fully generated and sent back.

    I find that the best thing to do when using this method is rely alot on CSS with the finished product That way the HTML is as small and simple as possible (a la css zen garden). the worst thing in the world, with any templating system, is generating loads of nested tables. it's alot easier to spend some design time up front and have a nice clean HTML layout, that way the XSL's job is a breeze.
    Sorry for bringing up an older thread but just got back to the forums after a while off. To answer the above it was for a blog that I wanted to output the archives in a specific way with a month/year header and each blog title below that month/year. It required a lot of recursion and tweaking to get the output as I wanted it. I'm willing to post it if anyone is interested.

    Quote Originally Posted by Andrew-J2000
    I find it amazing how we always seem to derive back to the common questions on the topic of XSL. I have never seen any mention of security and XSL, actual implementations or approaches people take. Fundamentally why are people not taking advantage of seperating XML, XSL fragments out, and have thousand lines of a mixture of XSL and HTML? Do you honestly write a thousand lines of XSL or is this chunks & chunks of HTML embedded in XSL markup (Be realistic)?
    I really cannot understand why the topic of XSL has not progressed past the extreme basics. I have never seen any PHP XSL implementations worth their salt. If anyone has some implementations or could point me to any new projects I would love to look over them.
    Well I wouldn't call my blog a full fledged application but it is something.

  16. #91
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    XInclude, Xpath or Xlink support in the xml stuff for PHP4 or PHP5 would be nice. It would be cool to be able to link xml fragments into other xml.

  17. #92
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what XInclude is, but XPath is supported by PHP5 and XLink is not that usefull.

  18. #93
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I wanted to use XLink to link xml fragments without the other xml get cluttered.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •