Subject: RE: [xsl] Apply-templates - how to omit top level element tags? From: "Mike Schinkel" <mikes@xxxxxxxxx> Date: Wed, 7 Sep 2005 20:23:42 -0400 |
Wendell: >> the canonical approach I've never understood the word "canonical" even though I've looked up the definition many times. How do you mean it? >> As for the strengths and weaknesses of the paradigm: not only is processing with templates not fraught with side-effects -- actually side-effects (in the strict technical sense of having the state of the processor being altered by the processing as it goes) is precisely what the XSLT paradigm is designed to *avoid*. I understand, and I've read that. But I believe you are referring to the strict technical use of the term and I am referring to the practive casual use of the term. So for example, I can have working code in XSLT and in my XML I add or change an element, or reorder elements, and the XSLT it no longer outputs that content correctly. To me that's a side effect. That's okay if the output is a few lines long where I can see error, but if my document is 50 pages long, I won't notice it without re-proofreading every time I touch the XSL, which is not practical. I understand that getting a validating schema can help, but those are hard to author and don't solve the problem entirely (according to an email reply to me from Michael Kay on this list.) >> You have a much stronger point in asking about the verifiability of the correctness of your output. Depending on how "correctness" is defined in given cases, however, it turns out that in practice most stylesheets turn out to be fairly transparent -- so even when they're difficult to verify formally, they turn out to be very dependable if constructed properly. Is there a concise set of rules for "properly constructed" stylesheets? One that doesn't require someone to already understand how to "think" in XSLT? >> Also, there are often brute-force methods of verification available, such as validating the output against the schema of your choice (shocking!). Of course writing that validation is a bigger job than writing correct XSLT, and since the schema is evolving, isn't practical. >> Likewise, this is an area that will be significantly improved by the schema-aware version of XSLT 2.0 (for those content to use W3C XML Schema). I look forward to that. That said, by not addressing the specific question, are you implying that what I asked about can't be done in XSLT, i.e. to have <Element>Text<SubElement/> More Text</Element> and, with an inline statement apply templates to <SubElement/> and output it's results along with "Text .. More Text" but not outputting the tags for <Element>? BTW, it seems like is should be such a simple thing. I've been a programmer for decades, but have also been a business man 1/2 that long, and I can really see where the programmer's pendantic-ness can cause business people to totally disrespect programmers. Business people just need to get jobs done and can't afford the luxury of jumping thru ten hoops for what appear to be purist reasons. I have been a pendantic programmer many times in my past, especially when I trained programmers and when I wrote a book on programming, but at this point I'm really the business man who just needs to get this done so I can generate enough revenue to pay my bills! Thanks again for all your help. -Mike -----Original Message----- From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx] Sent: Wednesday, September 07, 2005 7:15 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: [xsl] Apply-templates - how to omit top level element tags? Mike As others have suggested, the canonical approach to handling a given element in different ways is to qualify your templates with modes. This isn't the only approach, but it's probably the best path to explore. At 07:07 PM 9/7/2005, you wrote: >Jay Bryant>> Do you dislike the apply and match scheme (XSLT's native >idiom) > >Good question. Honestly I don't think I currently think that way so I >don't know (such as an English speaker has to translate from German to >be able to understand, whereas a fluent German speaker "thinks" in >German.) It seems fraught with side-effects, however, and it seems >hard to verify that output is "correct" when using that idiom. It's certainly true that those who are experienced in other kinds of programming frequently find they have to re-wire their brains to get the most out of XSLT. (Some have been fortunate to work with other functional languages and have already done the rewiring; others were never wired "wrong" to begin with.) As for the strengths and weaknesses of the paradigm: not only is processing with templates not fraught with side-effects -- actually side-effects (in the strict technical sense of having the state of the processor being altered by the processing as it goes) is precisely what the XSLT paradigm is designed to *avoid*. So, no side effects. While it is possible to get around this in XSLT, it's not easy. Yet even this can take getting used to: like walking on a floor after you're used to walking on tightropes. You have a much stronger point in asking about the verifiability of the correctness of your output. Depending on how "correctness" is defined in given cases, however, it turns out that in practice most stylesheets turn out to be fairly transparent -- so even when they're difficult to verify formally, they turn out to be very dependable if constructed properly. Also, there are often brute-force methods of verification available, such as validating the output against the schema of your choice (shocking!). Likewise, this is an area that will be significantly improved by the schema-aware version of XSLT 2.0 (for those content to use W3C XML Schema). Cheers, Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Apply-templates - how to , Mike Schinkel | Thread | RE: [xsl] Apply-templates - how to , Wendell Piez |
RE: [xsl] Moving an element to a ne, Graves, Jim \(CONTR\ | Date | RE: [xsl] Moving an element to a ne, Christopher R. Maden |
Month |