Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2006, 04:54 AM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL containing JSTL tags!

Hi All,
  Is it possible to have a stylesheet which will translate the incoming XML to a code snippet which contains JSTL taglibs. For example:

XSL (just for example)
---
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
   <xsl:text disable-output-escaping="yes"><![CDATA[<c:out value="Will it showup in browser!"/>]]></xsl:text>
 </xsl:template>
</xsl:stylesheet>


Please note, c:out is a JSTL tag to output the value. Is there is any way we can add intelligence to XSLT compiler to parse this - basically it has to parse the translated contents using JSP compiler.

Thanks

Free
 
Old August 1st, 2006, 05:17 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There are several options when generating JSP, or any other "not-quite-XML" syntax:

(a) use xsl:output method="text" and do all the serialization yourself

(b) use xsl:output method="xml" in conjunction with disable-output-escaping and/or XSLT 2.0 character maps

(c) generate pure XML and then postprocess it using some other technology

(d) write your own output method, if your XSLT processor allows this

(e) In the case of JSP, there is a pure XML syntax that's an alternative to the "non-XML" syntax using tags such as <%...%>.

I would recommend (e) as the cleanest way to go. None of the other options is very satisfactory.

See for example http://weblogs.java.net/blog/simongb...g_webap_6.html

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 1st, 2006, 05:46 AM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Micheal,
  Thank you so much for all the info. I would like to further have your advice on a very common issue when an XSLT is used to drive the front end screens. I wanted to componentize the dropdown list into a JSP taglib - such a taglib will talk to database to get its list and generate the <select>...</select> HTML block. If i want to use such a custom taglib along with XSL, please let me know the best way you recommend here. Lets assume, the XML on which XSL is working has only the selected value of the dropdown list and the translated contents should have the entire list and the selected value being highlighted.

Thanks.

Free
 
Old August 1st, 2006, 06:47 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You might be better off asking this on a JSP forum. I don't have much experience in this area.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 1st, 2006, 07:08 AM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Micheal,
  On the other way round, can i have a custom style sheet variable which will talk to my cached data to pull out the list. I will store something like below:
    <list name="colors">
          <option id="1" name="red"/>
            <option id="2" name="yellow"/>
        <option id="3" name="green"/>
        </list>

and in my data xml will have :
 <question id="1" listref="colors" style="listbox">
        <text>Color list</text>
    <value>1</value>
 </question>

I dont want the code lists to be part of each every XML which is getting translated, rather i want the XSL transformer to do this particular task. Please let me know your suggestions.

Thanks for your time.



Free
 
Old August 1st, 2006, 09:50 PM
Registered User
 
Join Date: Aug 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Again,
  Got a workaround - i used Xalan-J which will help me to introduce components in xsl which can talk to java. Any suggestions, welcome!

Thanks


Free





Similar Threads
Thread Thread Starter Forum Replies Last Post
html tags to reformed to xhtml standard using xsl swapbpl XSLT 12 May 8th, 2008 05:38 AM
XSL:FO Querying block id tags goldendase XSLT 4 September 20th, 2007 02:54 PM
namespaces appearing in tags after XSL translation mphare XSLT 4 February 20th, 2006 03:49 PM
JSTL aadz5 JSP Basics 1 August 8th, 2005 08:26 AM
JSTL mrkhairy JSP Basics 5 August 8th, 2003 04:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.