RE: x:transform using xsl:include
I encountered a problem pretty much similar to one of the previous posts : http://www.mail-archive.com/[EMAIL PROTECTED]/msg04896.html I read the source code of the Jakarta Standard Template Library 1.0.5 and got a doubt to it. In the org/apache/taglibs/standard/tag/common/xml/TransformSupport.java, we now have the following code fragment. /** * Retrieves a Source from the given Object, whether it be a String, * Reader, Node, or other supported types (even a Source already). * If 'url' is true, then we must be passed a String and will interpret * it as a URL. A null input always results in a null output. */ private Source getSource(Object o, String systemId) throws SAXException, ParserConfigurationException, IOException { if (o == null) return null; else if (o instanceof Source) { return (Source) o; } else if (o instanceof String) { // if we've got a string, chain to Reader below return getSource(new StringReader((String) o), systemId); } else if (o instanceof Reader) { // explicitly go through SAX to maintain control // over how relative external entities resolve XMLReader xr = XMLReaderFactory.createXMLReader(); xr.setEntityResolver( new ParseSupport.JstlEntityResolver(pageContext)); InputSource s = new InputSource((Reader) o); s.setSystemId(wrapSystemId(systemId)); Source result = new SAXSource(xr, s); result.setSystemId(wrapSystemId(systemId)); return result; } else if (o instanceof Node) { return new DOMSource((Node) o); } else if (o instanceof List) { // support 1-item List because our XPath processor outputs them List l = (List) o; if (l.size() == 1) { return getSource(l.get(0), systemId); // unwrap List } else { throw new IllegalArgumentException( Resources.getMessage(TRANSFORM_SOURCE_INVALID_LIST)); } } else { throw new IllegalArgumentException( Resources.getMessage(TRANSFORM_SOURCE_UNRECOGNIZED) + o.getClass()); } } --- I suppose the portion for DOM should be something like: --- } else if (o instanceof Node) { DOMSource ds = new DOMSource((Node) o); ds.setSystemId(systemId); return ds; } --- [Point]: set the SystemID attribute for the DOMSource object to be returned, as the current code is doing for the StreamSource object. I have just noticed this, will test my thought tommorow. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how to parseInt in jstl using express language?
i declare 2 variables,then i want to do some calculate.the result is 2.4 here,but my desire result is 2. How about using JSTL's standard fmt:formatNumber tag? MATSUHASHI - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: jstl transform question
when i write the code below: x:transform xml=${xml} xslt=${xslt} x:param name=gg value=0/ /x:transform my question is what the param useage here,how can i get the param in xsl file? A XSLT which accepts a param named gg and displays the param's value would look something like this: xsl:transform version=1.0 xmlns:xsl =http://www.w3.org/1999/XSL/Transform; xsl:param name=gg/ xsl:template match=/ xsl:messagegg is xsl:value-of select=$gg//xsl:message /xsl:template /xsl:transform - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: x:transform and body content
(BYou are importing the stylesheet into a variable named "default" as String. (BBut your x:transform tag does not refer to the variable "default" in which (Bthe stylesheet resides. Instead your x:transform refers to an undeclared (Bvariable called "xslt". Is this really what you want? I suppose you want (B x:transform xml="${dom}" xslt="${default}" (Brather than (B x:transform xml="${dom}" xslt="${xslt}" (B? (B (B (B (B (B (B (B"Mark R. Diggory" (B (B[EMAIL PROTECTED][EMAIL PROTECTED](B: Tag Libraries (BUsers List [EMAIL PROTECTED] (Brvard.educc: (B (B $B7oL>(B: x:transform and body (Bcontent (B2003/09/04 02:54 (B (B"Tag Libraries (B (BUsers List" $B$XJV?.(B (B (B$B$7$F$/[EMAIL PROTECTED](B (B (B (B (B (B (B (B (B (B (BI'm trying to dynamically set the parameters on an x:transform based on (Bthe params in the http request like below: (B (Bc:import var="default" url="/Study/DataSubsettingView.xsl"/ (B (Bx:transform xml="${dom}" xslt="${xslt}" (B c:forEach var="entry" items="${param}" (B c:if test="${entry.key ne 'var'}" (B x:param name="${entry.key}" value="${entry.value}"/ (B /c:if (B /c:forEach (B/x:transform (B (Bbut I keep getting (B (B27: Encountered illegal body of tag "x:transform" tag, given its (Battributes. (B (BIs there any way to do this dynamically? (B (B-Mark Diggory (B (B (B- (BTo unsubscribe, e-mail: [EMAIL PROTECTED] (BFor additional commands, e-mail: [EMAIL PROTECTED] (B (B (B (B (B (B (B- (BTo unsubscribe, e-mail: [EMAIL PROTECTED] (BFor additional commands, e-mail: [EMAIL PROTECTED]
RE: Using the standard (JSTL) tag library ...
(BAlso see this; (B (Bhttp://www.mail-archive.com/[EMAIL PROTECTED]/msg93186.html (B (B (B (B (B (B"Siggelkow, Bill" (B (B[EMAIL PROTECTED][EMAIL PROTECTED](B: "'Tag Libraries (BUsers List'" [EMAIL PROTECTED] (Birant.com cc: (B (B $B7oL>(B: RE: Using the standard (B(JSTL) tag library ... (B2003/07/31 21:17 (B (B"Tag Libraries (B (BUsers List" $B$XJV(B (B (B$B?.$7$F$/[EMAIL PROTECTED](B (B (B (B (B (B (B (B (B (B (BNot with Tomcat 4.1.18 -- Starting with Tomcat 5 you can -- Tomcat (Bimplements JSP 2.0 (formerly referred to as JSP 1.3) which allows EL (Banywhere within a page. (B (B-Original Message- (BFrom: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] (BSent: Thursday, July 31, 2003 6:55 AM (BTo: [EMAIL PROTECTED] (BSubject: Using the standard (JSTL) tag library ... (B (B (B (B (B (B (B (B (BI'm using JWSDP 1.1 that includes JSTL 1.0.3 under Tomcat 4.1.18 (B (BCan I use EL outside of the JSTL tags ? (B (BLike using ${param.server} in the code below: (B (Bframeset cols="20%,*" (Bframe name="allpackages" (Bsrc="allpackages.jsp?server=${param.server}" (Bframe name="details" src="details.jsp?server=${param.server}" (B/frameset (B (BSo far it doesn't work. I read that there are two versions: (B "This document describes an expression language (EL) for JSP. This (Bexpression (B language has two versions: one applicable to the JSP Standard Tag (BLibrary (JSTL), (B the other applicable to JSP 1.3." (from JavaServerPages: Standard (BTag Library V.10) (Bbut I even don't know what JSP version Tomcat 4.1 supports. (B (B-Jorge (B (B(Full example below) (B (B%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" % (B%@ page contentType="text/html"% (B!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" (B"http://www.w3.org/TR/html4/frameset.dtd" (Bhtml (Bhead (Blink rel="stylesheet" type="text/css" href="../css/default.css" / (Btitle (Bfmt:message key="TITLE_INDEX" (Bfmt:param value="${param.server}"/ (B/fmt:message (B/title (B/head (Bframeset rows="22%,*" (Bframe name="onheader" src="onheader.jsp?server=${param.server}" (Bframeset cols="20%,*" (Bframe name="allpackages" (Bsrc="allpackages.jsp?server=${param.server}" (Bframe name="details" src="details.jsp?server=${param.server}" (B/frameset (Bnoframes (Bbody (B/body (B/noframes (B/frameset (B/html (B (B- (BTo unsubscribe, e-mail: [EMAIL PROTECTED] (BFor additional commands, e-mail: [EMAIL PROTECTED] (B (B (B (B (B (B (B- (BTo unsubscribe, e-mail: [EMAIL PROTECTED] (BFor additional commands, e-mail: [EMAIL PROTECTED]
Re: XML help
Does this help? http://nagoya.apache.org/eyebrowse/SearchList?listId =[EMAIL PROTECTED]searchText=namespaces+in+x%3AparsedefaultField=subjectSearch=Search - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: JSTL c/x:out and XML-fragments
Here I cutpasted a code fragment of my JSP. h3raw Model/h3 c:import var=xslturl2 url=/WEB-INF/transform/IdentityTransform.xsl charEncoding=Shift_JIS/ %@ page import=java.io.StringWriter % %@ page import=javax.xml.transform.stream.StreamResult % % StringWriter sw = new StringWriter(); pageContext.setAttribute(resultString,sw); StreamResult outputResult = new StreamResult(sw); pageContext.setAttribute(outputResult, outputResult); % x:transform xml=${pipeline_final_output_String} xslt=${xslturl2} result=${outputResult}/ table border=1 trtdprec:out value=${resultString} escapeXml=true //pre/td/tr /table What is this doing? /WEB-INF/trasnform/IdentityTransform.xsl is a XSLT stylesheet which just copies the input source to the output result while changing the character encoding from UTF-8 to Shifg_JIS (Japanese local charaset). x:transform xml=${pipeline_final_output_String} xslt=${xslturl2} result=${outputResult}/ this fragment set the String format of the input XML (${pipeline_final_output_String} EL variable stands for it) to a variable ${resultString}. Then c:out value=${resultString} escapeXml=true / this tag prints the String which contains lot of s and s , but it is just a String -:). A cute portion of the above code might be that StringWriter class. This scriptlet trick the XSLT processor to write the transformation result as a plain String into the ${resultString}. Would this help? MATSUHASHI, kazuaki Japan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Whitespace generated by JSTL tags
Martin Cooper wrote: It will also have a noticeable - and undesirable - effect on any pre sections in the JSP page, causing them to be rendered incorrectly. You are right. I also want pre sections untouched. Hum... A possible countermeasure could be to write a custom Ant task which does the similar string relacement as the ant ReplaceRegExp task does while caring in/out status of PRE start/end tags (very easy to write if in awk :-). I will try this approach and come back here when finished. MATSUHASHI,kazuaki -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Advice needed for x:forEach select
How about applying x:transform tag to your original input XML to obtain another XML in which elements are ordered as you would like, then apply x:forEach and x:out tags to the latter XML? In the XSLT stylesheet, you would want a template like : xsl:template match= ... xsl:sort select= ... order=/ . /xsl:template If you show how your input XML document looks like, then I may be able to code a sample XSLT stylesheet and JSP fragment for you. Kazuaki Matsuhashi -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
How to use JSTL XSLT tags with result attribute
Hi, I am wondering how to use JSTL XML x:transform tag with result attribute. I am using the jakarta-taglibs/standard-1.0.2 with Tomcat 4.1.3 on Windows2000. I have a String variable ${pipeline_final_output_String} within the request scope in which a XML document is contained. I needed to transform the String via a simple identityTransform because the original XML is in a canonical-form; therefore no \n and no line indentation is used. I want to perform xsl:output indent=yes/ on the original. Also I want to print the variable's content while escaping and characters into lt; and amp; respectively; All these are meant to provide a debug-view to see XML as it is in the resulting HTML. I coded a JSP as follows : -- %@ taglib uri=/WEB-INF/x.tld prefix=x % h3raw Model/h3 c:import var=xslturl2 url=/WEB-INF/transform/IdentityTransform.xsl charEncoding=Shift_JIS/ %@ page import=javax.xml.transform.stream.StreamResult % %@ page import=javax.xml.transform.Result % %@ page import=java.io.StringWriter % % StringWriter sw = new StringWriter(); StreamResult outputResult = new StreamResult(sw); % x:transform xml=${pipeline_final_output_String} xslt=${xslturl2} result=outputResult/ % String escapedString = escape(sw.toString()); % table trtdpre%= escapedString %/pre/td/tr /table %! String escape(String s) { StringBuffer buffer = new StringBuffer(1024); if (s != null) { for (int i = 0; i s.length(); i++) { String c = s.substring(i,i+1); if (c.equals()) { buffer.append(lt;); } else if (c.equals()) { buffer.append(gt;); } else if (c.equals()) { buffer.append(amp;); } else { buffer.append(c); } } return buffer.toString(); } else { return null; } } When executed, a ServletException occured. The diagnostics says something as follows (in Japanse) : An error occured during evaluating the custome action attribute result with the value outputResult. When tried to convert a String outputResutl into the type of javax.xml.transform.Result, there is not a PropertyEditor to the type. I could not find a instructive articles on Web how to use result attribute of x:transform. Anyone knows how? -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: How to use JSTL XSLT tags with result attribute
Thank you, Hans. Inspired by your reply, I got the following JSP code. It worked! - %@ taglib uri=/WEB-INF/c.tld prefix=c % %@ taglib uri=/WEB-INF/x.tld prefix=x % h3raw Model/h3 c:import var=xslturl2 url=/WEB-INF/transform/IdentityTransform.xsl charEncoding=Shift_JIS/ %@ page import=java.io.StringWriter % %@ page import=javax.xml.transform.stream.StreamResult % % StringWriter sw = new StringWriter(); pageContext.setAttribute(resultString,sw); StreamResult outputResult = new StreamResult(sw); pageContext.setAttribute(outputResult, outputResult); % x:transform xml=${pipeline_final_output_String} xslt=${xslturl2} result=${outputResult}/ table border=1 trtdprec:out value=${resultString} escapeXml=true //pre/td/tr /table -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
skip x:parse, apply x:out straight to a pre-build DOM instance
Hello, I am wondering if it is possible in JSTL A usual use of JSLT XML tags goes as (1) by x:parse var=MyDOM ... tag, parse a XML document in String to obtain DOM instance in the scoped attribute specified by attribute var, (2) by x:out select=${MyDOM}///, pull the contents as String to show view. Consider a case where a org.w3c.dom.Document object has been created and stored within a request scope attribute before the JSP is invoked. In MVC architecture, this situation is likely to happen. Actually I want to do this in Struts : a Structs Action class produces a DOM and store it in the request scope, then forward to a JSP. In this situation I want to skip calling x:parse and apply x:out to the pre-built DOM instance. The reason why I want to skip is simple: avoid unnecessary XML parsing for better performance. If I have a DOM already, then why do I have to serialize the DOM into a String to pass to x:parse tag!? I have tried to find out if this is possible in various resources, but no such article/documentation I could find. I also tried such coding : c:set var=MyDOM value=${prebuild_DOM}/ x:out select=${MyDOM}//*/ then I was welcomed by a NullPointerException. Any idea? -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org
RE: namespaces in x:parse
Names that begin with xml are reserved by the XML specification. Yes, you are right. I was stupid, sorry... -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org
Re: skip x:parse, apply x:out straight to a pre-build DOM instance
(BThank you very much for your reply. It worked! (B (B MATSUHASHI,kazuaki (B QUICK Corp, (B Japan (B (B (B (B (B (B (BShawn Bayern (B (Bbayern@essent$B08@h(B: Tag Libraries Users List (B (Bially.net[EMAIL PROTECTED] (B (B cc: (B (B2002/11/15$B7oL>(B: Re: skip x:parse, apply (Bx:out straight to a (B00:04 pre-build DOM instance (B (B"Tag Libraries (B (BUsers List" $B$X(B (B (B$BJV?.$7$F$/$@$5(B (B (B$B$$(B (B (B (B (B (B (B (B (B (B (BOn Thu, 14 Nov 2002 [EMAIL PROTECTED] wrote: (B (B I also tried such coding : (B (B c:set var="MyDOM" value="${prebuild_DOM}"/ (B x:out select="${MyDOM}//*"/ (B (B then I was welcomed by a NullPointerException. (B (BYou can do it, but the syntax you're using is wrong. The JSTL tags don't (Bcare whether the DOM you're using has come from x:parse or from a (Bservlet. But either way, you must refer to it using XPath variables, not (Bthe JSTL EL inside the 'select' attribute. Thus, you'd write (B (B x:out select="$MyDOM//*" / (B (B-- (BShawn Bayern (B"JSTL in Action" http://www.manning.com/bayern (B (B (B-- (BTo unsubscribe, e-mail: (Bmailto:[EMAIL PROTECTED] (BFor additional commands, e-mail: (Bmailto:[EMAIL PROTECTED] (B (B (B (B (B (B (B-- (BTo unsubscribe, e-mail: mailto:[EMAIL PROTECTED] (BFor additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: namespaces in x:parse
Hi, In the last Oct - Nov time, I posted an issue to this Taglib User List, which is very similar to your problem. The title of my initial post was Does JSTL XML taglibs ignore XMLNamespace of input document?(later I found this title was incorrect, not forcusing my problem precisely) dated at 09 Oct 2002. Shawn Bayern kindly responded to my post which was followed by several e-mail exchanges between Shawn and me. Unfortunately you can not see them at the Taglib User List archieve at http://www.mail-archive.com/taglibs-user;jakarta.apache.org/ for some reason (may be due to my mistake). If you require I can send the record to you. The simple answer I got from Shawn Bayarn was that, as far as JSTL1.0 specification tells, you can NOT use the namespace prefixes in XPath expressions in x:... select=xpath. If you want to process an input XML document with explicit Namespaces (in other word, qualified elements), you need to explicitly use the local-name() function and namespace-uri() function, or name() function defined by XPath1.0 specification to make your XPath well-matching against the input document. The way you can do in JSTL1.0 would be to write something like: x:set var=mediumColor scope=application select=string($colorsXml//stylesheet[namespace-uri() =http://www.w3.org/1999/XSL/Transform]/variable[namespace-uri() =http://www.w3.org/1999/XSL/Transform and @name='medium']/@select) / (sorry, I did not check if this code runs properly for you. I meant to show you how to use the namespace-url() function to make the XPath valid without using namespace prefixes ...). Shawn's JSTL Action book has a section where he explained what you can and cannot do in XPath expression in the JSTL1.0 way. In there you would find more precise explanation than my (may be inaccurate) note. -- When I got to know that I can not use XML Namespace prefixes in XPath expression in x:... tags and therefore the XPath expressions tend to be very long and hard-to-read/write, I wanted to find out if there is any possibility for JSTL1.0 specification betterment. So I did a quick hack (modify taglib implementation to allow namespace prefixes in xpath). I reached a conclusion that a specification betterment seems to be possible. At the end of discussion, Shawn mentioned an idea of introducing a new tag by which you can register combinations of Namespace prefix and URI which to be reffered from the XPath expressions within x:... select=xpath tags. Consider that new tag is introduced, your code could look something like: c:import var=colors url=/mwr/colors.xsl/ x:parse xml=${colors} var=colorsXml/ x:registerNamespace prefix=xsl uri =http://www.w3.org/1999/XSL/Transform; scope=.../ !-- registerNamespace tag is NOT defined in the JSTL1.0 specification !!! -- x:set var=mediumColor scope=application select=string($colorsXml//xsl:stylesheet/xsl:variable[@name ='medium']/@select) / ... This code looks short, much readable, quite in synch with the XSLT way of using XPath! Don't you think so? MATSUHASHI,kazuaki (FAMILY,given) QUICK Corp Japan [EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org
RE: namespaces in x:parse
Rather than this x:registerNamespace prefix=xsl uri =http://www.w3.org/1999/XSL/Transform; scope=.../ !-- registerNamespace tag is NOT defined in the JSTL1.0 specification !!! -- following name might look more familiar to anybody; no explanation needed. x:xmlns prefix=... uri=... scope=.../ MATSUHASHI,kazuaki QUICK Corp Japan -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org
Re: Does JSTL XML taglibs ignore XMLNamespace of input document?
I have worked out about this issue and I believe I have got an idea of betterment to the jakarta standard taglibs1.0.x and possibly to the JSTL specification. Here I refrain the initial issue I raised just to remind it. I coded the following JSP page - % taglib uri=/WEB-INF/x.tld prefix=x % x:parse var=NoNSabboon/b/a/x:parse x:parse var=WithNSn:a xmlns:n =someNamespacen:bbaan/n:b/n:a/x:parse $NoNS/a/b=x:out select=$NoNS/a/b/br $WithNS/a/b=x:out select=$WithNS/a/b/br $WithNS/n:a/n:b=x:out select=$WithNS/n:a/n:b/ - The only difference between $NoNS object and $WithNS object is XML Namespace usage. I got the following response from the application. - $NoNS/a/b=boon $WithNS/a/b= $WithNS/n:a/n:b= - I could not get baan output. I looked at the taglibs1.0.2 source code and studied Jaxen. Then I did an experiment (source code change) locally on my PC. I modifed the source code of org.apache.taglibs.standard.tag.common.xml.XPathUtil class slightly as follows: - /** * Returns a String given an XPath expression and a single context * Node. */ public String valueOf(Node n, String xpath) throws SAXPathException { staticInit(); XPath xp = new DOMXPath(xpath); //--- modification by MATSUHASHI,kazuaki-- start // // lookup a Map which should contain pairs of XML Namespace prefix // and URI to be used within XPath expression, then put them into // SimpleNamespaceContext object which will be refered by jaxen engine // // just insert the following statements, that's all Map nsCollection = (Map)pageContext.getAttribute(inputDocumentXmlNamespaces); if (nsCollection != null) { Set prefixes = nsCollection.keySet(); Iterator nsIterator = prefixes.iterator(); while (nsIterator.hasNext()) { String prefix = (String)nsIterator.next(); String nsuri = (String)nsCollection.get(prefix); System.out.println(prefix= + prefix); System.out.println(NSURI = + nsuri); nc.addNamespace(prefix, nsuri); } } //--- modification by MATSUHASHI,kazuaki--- end // return xp.valueOf(getLocalContext(n)); return xp.stringValueOf(getLocalContext(n)); } - The JSP to test the new class is as follows - % taglib uri=/WEB-INF/x.tld prefix=x % html body h2An experimental modification of JSTL XPath/h2 h3to enable access XML with SOME Namespaces/h3 pcase1 : input XML using NO Namespace --- possible to obtain boon by jakarta-taglibs standard-1.0.2/p x:parse var=NoNSabboon/b/a/x:parse table border=1 trtdXML/tdtdlt;alt;bboonlt;/blt;/a/td/tr trtdXPath/tdtd$NoNS/a/b/td/tr trtdvalue/td tdx:out select=$NoNS/a/b//td/tr /table brbr pcase2 :input XML using some Namespaces --- impossible to obtain baan by standard-1.0.2, but enabled by code modification/p x:parse var=WithNSn:a xmlns:n =someNamespaceURIn:bbaan/n:b/n:a/x:parse % page import=java.util.HashMap % % HashMap ns = new HashMap(); ns.put(p, someNamespaceURI); pageContext.setAttribute(inputDocumentXmlNamespaces, ns); % table border=1 trtdXML/tdtdlt;n:a xmlns:n=someNamespaceURI lt;n:bbaanlt;/n:blt;/n:a/td/tr trtdXPath/tdtd$WithNS/p:a/p:b/td/tr trtdvalue/td tdx:out select=$WithNS/p:a/p:b//td/tr /table /body /html - Then I could get the following display: - An experimental modification of JSTL XPath to enable access XML with SOME Namespaces case1 : input XML using NO Namespace --- possible to obtain boon by jakarta-taglibs standard-1.0.2 XML abboon/b/a XPath $NoNS/a/b value boon case2 :input XML using some Namespaces --- impossible to obtain baan by standard-1.0.2, enabled by code modification XML n:a xmlns:n=someNamespaceURIn:bbaan/n:b/n:a XPath $WithNS/p:a/p:b value baan - The code modification above is meant to inform Jaxen about the Namespace prefixes and URIs to be used within the XPath expression. The URI string is significant which should match with the URI string used in the input XML document, but the prefix is not really significant --- the prefix characters in the XPath does not have to be the same as the prefix characters used in the XML. The modification was enough to deal with (though just to print the text
Re: Does JSTL XML taglibs ignore XMLNamespace of input document?
Shawn Bayern wrote : In XPath, n:a is not a valid step; it does not refer, as you seem to be expecting, to the node named 'a' in the namespace identified by prefix 'n'. If you want to refer to this node, you'll probably want to use the name() and namespace-uri() functions in XPath. Yes, I fully understand what you say, but ... what I want is shortness of the JSP code. Consider the following example XML: a fairy long string of NamespaceURIs - SOAP-ENV:Envelope xmlns:SOAP-ENV =http://schemas.xmlsoap.org/soap/envelope/; SOAP-ENV:encodingStyle =http://schemas.xmlsoap.org/soap/encoding/; SOAP-ENV:Header t:Transaction xmlns:t=http://baseball.azb.co.jp/Apache/; SOAP-ENV:mustUnderstand=1 5 /t:Transaction /SOAP-ENV:Header SOAP-ENV:Body m:getPitchingResult xmlns:m =http://baseball.azb.co.jp/Apache/DataStore/; m:nameAkinobu Yoshida/m:name m:No00/m:No /m:getPitchingResult /SOAP-ENV:Body /SOAP-ENV:Envelope - Then if I want to obtain the string value of m:name element, the JSP with legal XPath would look like (I think) - x:out select=$foo/Envelope[namespace-uri() ='http://schemas.xmlsoap.org/soap/envelope']/Body[namespace-uri() ='http://schemas.xmlsoap.org/soap/envelope']/getPitchingResult[namespace-uri )='http://baseball.azb.co.jp/Apache/DataStore/']/name[namespace-uri() ='http://baseball.azb.co.jp/Apache/DataStore/']/ - This one line of code is too long! Don't you think so? How can I make this shorter? I believe that one of the greate benefits of the custom-tag technology is that it makes the JSP code shorter, easy to read. The way I suggested may not be seen orthodx. It is really a way of convenience. However I would like to point out why Namespaces in XML specification introduced namespace prefix itself? Isn't it a way of convenience to make XML documents withNamespaces shorter, easy to read? See the XPath standard or chapter 8 of JSTL in Action. Yes, definitely. I ordered it to amazon.com and waiting for I appreciate your comment very much. Kazuaki Matsuhashi QUICK Corp, Japan -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org
Re: Does JSTL XML taglibs ignore XMLNamespace of input document?
additive: - x:out select=$foo/Envelope[namespace-uri() ='http://schemas.xmlsoap.org/soap/envelope']/Body[namespace-uri() ='http://schemas.xmlsoap.org/soap/envelope']/getPitchingResult[namespace-uri )='http://baseball.azb.co.jp/Apache/DataStore/']/name[namespace-uri() ='http://baseball.azb.co.jp/Apache/DataStore/']/ - This long line could be shorten by the way I suggested as follows : - c:set target=ns property=s value= http://schemas.xmlsoap.org/soap/envelope/ c:set target=ns property=t value= http://baseball.azb.co.jp/Apache/DataStore// x:out select=$foo/s:Envelpe/s:Body/t:getPitchingResult/t:name namespaces =${ns}/ - Kazuaki Matsuhashi QUICK Corp, Japan -- To unsubscribe, e-mail: mailto:taglibs-user-unsubscribe;jakarta.apache.org For additional commands, e-mail: mailto:taglibs-user-help;jakarta.apache.org
Does JSTL XML taglibs ignore XMLNamespace of input document?
Hi, I just started learning JSTL, am especially interested in XML-related taglibs. I use jakarta-taglibs/standard-1.0.1 on tomcat4.1.3. I coded the following JSP page - %@ taglib uri=/WEB-INF/x.tld prefix=x % x:parse var=NoNSabboon/b/a/x:parse x:parse var=WithNSn:a xmlns:n =someNamespacen:bbaan/n:b/n:a/x:parse $NoNS/a/b=x:out select=$NoNS/a/b/br $WithNS/a/b=x:out select=$WithNS/a/b/br $WithNS/n:a/n:b=x:out select=$WithNS/n:a/n:b/ - The only difference between $NoNS object and $WithNS object is XML Namespace usage. I got the following response from the application. - $NoNS/a/b=boon $WithNS/a/b= $WithNS/n:a/n:b= - I can not get baan output. I do not see how the XPath expression should be written for $WithNS object using JSTL taglib I read JSTL specification document and as many resources on the web as I could find, and I have a feel that the JSTL specification is not explicit enough how to deal with XML namespace used in the input source. Am I wrong? If I am wrong and the told how to solve this, I would be very much pleased. -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]