JSP returning XML with one slight flaw....
I have created a web service using JAXB 2.0 which queries a database and returns the queried data as KML (Keyhole Markup Language) for use in Google Earth. The service works great, and is returning the KML just as intended, however, the service is being called by a JSP, which in turn returns the KML by whatever client runs the JSP. I am re-learning JSP after having dabbled in it two years ago, and somewhere along the line the JSP is placing a "\n" (blank line) in the first line, which causes most XML parsers to get very angry at you. The JSP is very simple, and I just dont see where this blank line is coming from:
<%@ page contentType="application/vnd.google-earth.kml+xml; charset=UTF-8" %>
<% try {
com.xxx.kmlpages.KMLWebServiceImplService service = new com.xxx.kmlpages.KMLWebServiceImplService();
com.xxx.kmlpages.KMLWebServiceImpl port = service.getKMLWebServiceImplPort();
java.lang.String result = port.processKML();
out.print(result);
} catch (Exception ex) {
} %>
Normally the xml parser wants to see:
<?xml version="1.0" encoding="UTF-8" ?>
as the first line, but instead the JSP returns that as the second line with a blank line first.
Any idea what in my JSP is causing this blank line?
Message was edited by:
Smiler
I just ran through the debugger, and the "result" which is to be out.print'ed, is exactly as it is supposed to be. There is nothing in the result creating a blank line. So SOMEHOW this very simple JSP is printing a blank line before printing the returned result.
Smiler wrote:
Quite the helpful forum...
After digging around, I came across this webpage:
http://www-128.ibm.com/developerworks/java/library/j-dynxml.html
In it, is described:
"It's important to note that the JSP page compiler will remove only the characters making up the tag and its contents. If you place a JSP tag on a new line, the page compiler will remove everything but the new line (because that is not part of the tag). For example, suppose we add the content type tag to our new JSP page like so:
<%@ page contentType="text/xml;charset=ISO-8859-1" %>
<?xml version="1.0" encoding="ISO-8859-1"?>
<Flights>
<AirCarrier>AA</AirCarrier>
<FlightNumber>700</FlightNumber>
<FlightSegment>
In this case, the page compiler will remove the page directive on the first line, leaving a blank line before the <?xml...?> version tag. In XML documents, the XML version tag must be on the first line, so this example would cause an error in an XML parser."
Well, it seems the simple solution to my problem then is to change my page declarative to:
<%@ page contentType="application/vnd.google-earth.kml+xml" %><%--
--%><% try {
Notice the difference?Hi. I have a similar problem in our program. We are putting the xml in a session and forwarding to jsp where we print it. This is creating a blank first line which causes an error on safari, firefox except ie.
How do you suggest i correct this? Any help /direction in this regard would be appreciated. Thanks!
Rohan
Similar Messages
-
Revision: 4804
Author: [email protected]
Date: 2009-02-02 17:56:22 -0800 (Mon, 02 Feb 2009)
Log Message:
Bugs: LCDS-548: add code to deal with contentType="application/xml" with one parameter (avoid
name/value encoding in that case)
LCDS-405: baseURL on HTTPMultiService should accept URLs which start with "/"
Added convertParametersHandler and convertResultsHandler function hooks to RemoteObject
to support framework code which wants to modify the service behavior.
Moved "properties" from rpc/http/AbstractOperation to rpc/AbstractOperation so we can use
it for customizing the handling of remote object results
Couple of minor ASDoc fixes and one tab -> spaces change
Doc: minor asdoc edits
QE: LCDS QE will verify the bugs in this one
Reviewers: Mete, Pete, Seth, Ed reviewed different parts of this checkin
Ticket Links:
http://bugs.adobe.com/jira/browse/LCDS-548
http://bugs.adobe.com/jira/browse/LCDS-405
Modified Paths:
flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/AbstractInvoker.as
flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/AbstractOperation.as
flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/http/AbstractOperation.as
flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/http/HTTPMultiService.as
flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/http/Operation.as
flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/remoting/Operation.as
flex/sdk/trunk/frameworks/projects/rpc/src/mx/rpc/remoting/RemoteObject.asHello,
How about this as an alternative:
Use a functional global which has 3 cases:
1. open config file - it opens the config file and reads the contents into a string (which is the functional global data), and you only do this one time at the beginning of the program.
2. edit config data - it edits the string, which are really the contents of the file, but doesn't worry about writing to the file. you could even get fancy here, and allow an array of tags and an array of values as input, and it would go update/edit all the tags to have the corresponding values.
3. close config file - it writes the current string data (the functional global data) to the file and closes it.
Using the functions in the string palette, I think you'll find most of the code for that module/functional global will be easy to write.
I hope this helps!
Best Regards,
JLS
Best,
JLS
Sixclear -
Hi ,
I am trying to generate a xml as a response to the AJAX query by UI. The code does not work. Can anyone please help.? This is my JSP:
Note: The one thing I noted was if I remove the content type(The code renders the string). But similar thing does not work on IE7.
<%
response.setContentType("text/xml");
String nVal = request.getParameter("nVal");
String enable=request.getParameter("check");
StringBuffer sb = new StringBuffer();
//Generate XML Response
sb.append("<?xml version="1.0" encoding="utf-8" ?>");
sb.append(" <DimQueryResults>");
sb.append("<Dimension displayName="BY TOPIC">");
sb.append("<DimValue displayName="Accounting" NValue="4294966629" enable="1 " count="60" /> ");
sb.append("<DimValue displayName="Audit & Attest" NValue="4294966607" enable="1" count="70" /> ");
sb.append("<DimValue displayName="Business Valuation and Litigation Services" NValue="4294966569" enable="1" count="80" /> ");
sb.append("<DimValue displayName="Career/Personal Development" NValue="4294966562" enable="1" count="100" /> ");
sb.append("<DimValue displayName="Consulting Services" NValue="4294966561" enable="1" count="10" />");
sb.append("<DimValue displayName="Ethics" NValue="4294967247" enable="1" count="10" /> ");
sb.append("<DimValue displayName="Financial Management" NValue="4294966560" enable="1" count="10" /> ");
sb.append("<DimValue displayName="Fraud Detection and Prevention" NValue="4294966543" enable="1" count="10" /> ");
sb.append("<DimValue displayName="Internal Controls" NValue="4294966542" enable="1" count="10" /> ");
sb.append("</Dimension>");
sb.append("<Dimension displayName="BY CPE CREDIT">");
sb.append(" <DimValue displayName="6 - 10 CPE" NValue="4294966629" enable="1" count="60" /> ");
sb.append("<DimValue displayName="16 - 20 CPE" NValue="4294966607" enable="1" count="70" /> ");
sb.append(" <DimValue displayName="1 - 5 CPE" NValue="4294966569" enable="1" count="80" /> ");
sb.append("<DimValue displayName="11 - 15 CPE" NValue="4294966562" enable="1" count="100" /> ");
sb.append("<DimValue displayName="21 - 25 CPE" NValue="4294966561" enable="1" count="10" /> ");
sb.append("</Dimension>");
sb.append("<Dimension displayName="BY FORMAT">");
sb.append("<DimValue displayName="DVD/Manual" NValue="4294967141" enable="1" count="60" /> ");
sb.append("<DimValue displayName="Webcast" NValue="4294965697" enable="1" count="70" /> ");
sb.append("<DimValue displayName="CD-ROM" NValue="4294967163" enable="1" count="80" /> ");
sb.append("<DimValue displayName="Online" NValue="4294967116" enable="1" count="100" />");
sb.append("<DimValue displayName="Conference" NValue="4294964809" enable="1" count="10" /> ");
sb.append("<DimValue displayName="Text" NValue="4294967170" enable="1" count="10" />");
sb.append("</Dimension>");
sb.append("</DimQueryResults>");
sb.append("</xml>");
out.println(sb.toString());
%>What doesn't work about it?
Does it throw an exception?
Does it raise a javascript error?
Does it make your coffee too strong?
My first response is
- Scriptlet code belongs in a Servlet, not a JSP
- ALl the scriptlet code is doing is out.println anyway - why do you not just have the XML as template text in your JSP?
At a guess, the extra carriage returns added to the response by JSP will be screwing with your response xml. Carriage returns at the start of it in particular.
Either
- Put it in a servlet
- use JSP properly -
XMLElement not returning XML with xsql:query
I am trying to use a select statement containing XMLElement, XMLAgg and XMLForest functions from a xsql servlet.
<page xmlns:xsql="urn:oracle-xsql" connection="HOM_WISP">
<xsql:query row-element="" rowset-element="STATEMENT">
SELECT
XMLElement("GROUP", XMLAttributes(gst_group AS GSTGroup,
display_group AS DisplayGroup),
XMLAgg(
XMLElement("PAYMENTDETAIL",
XMLForest(phase_type,
contract_num,
mark_block,
cut_permit,
destination,
stratum_code,
species_code,
sort_code,
truck,
back_haul,
uom_desc,
uom_code,
gst_exempt_flag,
pay_deduct_desc,
actual_rate,
gst_registrant_num,
load_count,
quantity,
volume,
earnings)))).getClobVal() as PAYMENTITEM
FROM ws_cntr_statement_vw
GROUP BY gst_group, display_group
</xsql:query>
</page>
When XML is returned only the out most XML as follows the inner elements are text. I truncated the output but you can see that GROUP and PAYMENTDETAIL are not elements but text. I want them all to be elements.
<page>
<STATEMENT><PAYMENTITEM><GROUP GSTGROUP="1_GST" DISPLAYGROUP="2_RETRO"><PAYMENTDETAIL><PHASE_TYPE>Purchasing</PHASE_TYPE><CONTRACT_NUM>3346</CONTRACT_NUM><MARK_BLOCK>GA500B-0001</MARK_BLOCK><DESTINATION>LC</DESTINATION><STRATUM_CODE>18</STRATUM_CODE><SPECIES_CODE>SP</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>-9.32</ACTUAL_RATE><GST_REGISTRANT_NUM>R102090347</GST_REGISTRANT_NUM><LOAD_COUNT>1</LOAD_COUNT><QUANTITY>28440</QUANTITY><VOLUME>36.68</VOLUME><EARNINGS>-265.06</EARNINGS></PAYMENTDETAIL></GROUP></PAYMENTITEM><PAYMENTITEM><GROUP GSTGROUP="1_GST" DISPLAYGROUP="4_CNTRPAY"><PAYMENTDETAIL><PHASE_TYPE>ADV/REC NO CONTRACT</PHASE_TYPE><UOM_DESC>flat</UOM_DESC><UOM_CODE>FL</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><PAY_DEDUCT_DESC>PAY 12 ADVANCE RECOVERY ES4922</PAY_DEDUCT_DESC><ACTUAL_RATE>32644.87</ACTUAL_RATE><GST_REGISTRANT_NUM>R123330532</GST_REGISTRANT_NUM><EARNINGS>-32644.87</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>FIREWOOD/STUMPAGE ALL BLOCKS</PHASE_TYPE><UOM_DESC>flat</UOM_DESC><UOM_CODE>FL</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><PAY_DEDUCT_DESC>FIREWOOD LOAD # 151819</PAY_DEDUCT_DESC><ACTUAL_RATE>25</ACTUAL_RATE><GST_REGISTRANT_NUM>R123083735</GST_REGISTRANT_NUM><EARNINGS>-25</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>SB#2 PAY RD USE</PHASE_TYPE><UOM_DESC>flat</UOM_DESC><UOM_CODE>FL</UOM_CODE><GST_EXEMPT_FLAG>1</GST_EXEMPT_FLAG><PAY_DEDUCT_DESC>ROAD USE ES4208 BLOCK 9</PAY_DEDUCT_DESC><ACTUAL_RATE>898.1</ACTUAL_RATE><EARNINGS>898.1</EARNINGS></PAYMENTDETAIL></GROUP></PAYMENTITEM><PAYMENTITEM><GROUP GSTGROUP="1_GST" DISPLAYGROUP="1_ORIGINAL"><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0026</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>FED</DESTINATION><STRATUM_CODE>01</STRATUM_CODE><SPECIES_CODE>FI</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>19.5</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>14</LOAD_COUNT><QUANTITY>498300</QUANTITY><VOLUME>579.54</VOLUME><EARNINGS>9716.85</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0026</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>LC</DESTINATION><STRATUM_CODE>06</STRATUM_CODE><SPECIES_CODE>FI</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>19.5</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>33</LOAD_COUNT><QUANTITY>1096770</QUANTITY><VOLUME>1300.24</VOLUME><EARNINGS>21387.07</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0026</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>LC</DESTINATION><STRATUM_CODE>13</STRATUM_CODE><SPECIES_CODE>LO</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>19.5</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>84</LOAD_COUNT><QUANTITY>3219510</QUANTITY><VOLUME>3990.95</VOLUME><EARNINGS>62780.68</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0026</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>LC</DESTINATION><STRATUM_CODE>21</STRATUM_CODE><SPECIES_CODE>MX</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>19.5</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>2</LOAD_COUNT><QUANTITY>71030</QUANTITY><VOLUME>91.4</VOLUME><EARNINGS>1385.09</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0026</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>PUL</DESTINATION><STRATUM_CODE>16</STRATUM_CODE><SPECIES_CODE>LO</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>18</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>3</LOAD_COUNT><QUANTITY>104980</QUANTITY><VOLUME>173.46</VOLUME><EARNINGS>1889.64</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0030</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>LC</DESTINATION><STRATUM_CODE>06</STRATUM_CODE><SPECIES_CODE>FI</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>19.5</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>15</LOAD_COUNT><QUANTITY>514800</QUANTITY><VOLUME>610.27</VOLUME><EARNINGS>10038.64</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0030</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>LC</DESTINATION><STRATUM_CODE>18</STRATUM_CODE><SPECIES_CODE>SP</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>19.5</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>1</LOAD_COUNT><QUANTITY>35740</QUANTITY><VOLUME>46.43</VOLUME><EARNINGS>696.93</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>2731</CONTRACT_NUM><MARK_BLOCK>ES4334-0030</MARK_BLOCK><CUT_PERMIT>334</CUT_PERMIT><DESTINATION>PUL</DESTINATION><STRATUM_CODE>16</STRATUM_CODE><SPECIES_CODE>LO</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>18</ACTUAL_RATE><GST_REGISTRANT_NUM>R104985114</GST_REGISTRANT_NUM><LOAD_COUNT>3</LOAD_COUNT><QUANTITY>100280</QUANTITY><VOLUME>165.68</VOLUME><EARNINGS>1805.04</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>3350</CONTRACT_NUM><MARK_BLOCK>ES4922-0026</MARK_BLOCK><CUT_PERMIT>922</CUT_PERMIT><DESTINATION>LC</DESTINATION><STRATUM_CODE>06</STRATUM_CODE><SPECIES_CODE>FI</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>37</ACTUAL_RATE><GST_REGISTRANT_NUM>R123330532</GST_REGISTRANT_NUM><LOAD_COUNT>5</LOAD_COUNT><QUANTITY>197320</QUANTITY><VOLUME>233.92</VOLUME><EARNINGS>7300.84</EARNINGS></PAYMENTDETAIL><PAYMENTDETAIL><PHASE_TYPE>Logging</PHASE_TYPE><CONTRACT_NUM>3350</CONTRACT_NUM><MARK_BLOCK>ES4922-0027</MARK_BLOCK><CUT_PERMIT>922</CUT_PERMIT><DESTINATION>LC</DESTINATION><STRATUM_CODE>21</STRATUM_CODE><SPECIES_CODE>MX</SPECIES_CODE><UOM_DESC>tonne</UOM_DESC><UOM_CODE>MT</UOM_CODE><GST_EXEMPT_FLAG>0</GST_EXEMPT_FLAG><ACTUAL_RATE>37</ACTUAL_RATE><GST_REGISTRANT_NUM>R123330532</GST_REGISTRANT_NUM><LOAD_COUNT>1</LOAD_COUNT><QUANTITY>38920</QUANTITY><VOLUME>50.08</VOLUME><EARNINGS>1440.04</EARNINGS></PAYMENTDETAIL><Sorry I guess I haven't explained very well. When I am issuing the SELECT statement which uses XMLElement I have to convert output to string in order to have a column alais PAYMENTITEM. It is then not reconnized as XML in the
xsql:query call
If I do not assign a alias to query I get following error
oracle.xml.sql.OracleXMLSQLException: Character ',' is not allowed in an XML tag
If I assign without using getClobVal() I get this error
oracle.xml.sql.OracleXMLSQLException: Conversion to String failed
If I then use the getClobVal() to assign column alias it appears as if entire result set is now a string then <> tag delimiters are now show with "<" signs instead. -
Data service (DB adapter) returns XML with missing collection's content
Hello.
I am facing problem with DB adapter connected to MySQL database.
When I use select from 1-2 tables (connected by master-detail relationship) adapter works fine.
When I use more than 2 tables adapter returns only master table and empty detail collections.
This is example of 2 tables (master-detail) response
<BasketItemCollection>
<BasketItem>
<basketItemId>234</basketItemId>
<loggedUserId>126</loggedUserId>
<itemTitle>itemTitle</itemTitle>
<itemPartNo/>
<itemPrice>301.26</itemPrice>
<itemVat>0.0</itemVat>
<itemQty>1</itemQty>
<itemNote/>
<dateInsert>2009-10-08T16:07:30.000+02:00</dateInsert>
<basketInvoiceId>44</basketInvoiceId>
<documents>
<docId>560</docId>
<dateCreated>2011-08-23T09:14:52.000+02:00</dateCreated>
<available>false</available>
<passwordProtected xsi:nil="true"/>
</documents>
</BasketItem>
</BasketItemCollection>
This is example of response after adding 1 master table
<BasketInvoiceCollection>
<BasketInvoice>
<basketInvoiceId>44</basketInvoiceId>
<browserId>371</browserId>
<loggedUserId>126</loggedUserId>
<createDate>2009-10-08T16:08:17.000+02:00</createDate>
<statusId>7</statusId>
<deliveryCompany xsi:nil="true"/>
<deliveryName>Alena Molnarova</deliveryName>
<deliveryStreet>fgh</deliveryStreet>
<deliveryCity>fgh</deliveryCity>
<deliveryZip>9054</deliveryZip>
<deliveryCountry>fghfgh</deliveryCountry>
<internalInvoiceId xsi:nil="true"/>
<userNote>fghfgh</userNote>
<userLng>sk</userLng>
<paymentMethod>cash_on_delivery</paymentMethod>
<deliveryMethod>Prevzatie tovaru osobne</deliveryMethod>
<htmlCode xsi:nil="true"/>
<currency>skk</currency>
<basketItemCollection/>
</BasketInvoice>
</BasketInvoiceCollection>
basketItemCollection is here empty.
Where can be a problem hidden?
Thanks in advance for any helpHi.
JDeveloper use aliase names for tables by default so aliases t0, t1, t3 are used for tables basketinvoice, basketitem, documents.
I think there is some connection to table. Collection of basketinvoicepayments table is missing when 3 tables select and 2 tables select too.
Table basketinvoicepayments is child table and it's element is missing even when relationship is 1:M or 1:1 (Foreign Key on Child table). -
Best way to create, modify, XML with JSP ? HELP
Hi friends,
As i am new to XML,
I know there are two APIs used for XML processing, i want to know as a begineer level, which API
is easy and good to implement XML with JSP.
1) SAX
2) DOM
i want to make a log file in XML, so on web page it will be displayed on HTML form through XSL.
Since there is good tutorial on http://www.w3schools.com/dom
but i think its HTML dom
I want XML procession through JAVA CODE , what should i use ? and give some good tutorials on XML DOM
that is used with JAVA / JSP.
HELP.
Edited by: Ghanshyam on Sep 19, 2007 3:24 PMWell what i think is you gonna checkout with your requirements before implementing any of the popular XML parsing mechnisms.
If you are intrested in faster processing @sacrifising a gud amount of your Memory,DOM is the one which you are looking for.
If you are instrested in Managing your memory and but if you are ok with sacrifising speed SAX is the best solution.it works on what is called a push technology.
and if you think either way you might have to look towards a pull parser which is StAX (Streaming API for XML Parsing)
it'd be a gr8 idea if you can go through the below article which explians about each of the parsing mechanisms
http://www.stylusstudio.com/xml/parser.html#*
coming back to helpful resources as far java is concern checkout the below link which might be of some help.
and the main thing is that all of these parser there is a defined specification you might find implementations of different vendors on this.
eg:Sun Provides one with JDK itself,same as IBM provides one,oracle does the same & so on...
your first task would be to focus on one such implementation which can cater your requirements.
DOM:*
Basic Parsing Objects / Interfaces Involved while DOM parsing:
http://www.w3.org/TR/DOM-Level-2-Core/java-binding.html
Breif Overview & few important API details:
http://www.developerlife.com/domintro/default.htm
Simple Example:
http://www.brics.dk/~amoeller/XML/programming/domexample.html
Others:
http://www.roseindia.net/xml/dom/
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPDOM.html#wp79994
http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/1_read.html
SAX:*
http://www.javacommerce.com/displaypage.jsp?name=saxparser1.sql&id=18232
http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/index.htm
http://java.sun.com/developer/Books/xmljava/ch03.pdf
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPSAX.html#wp69937
http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=6
StAX:*
http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP2.html
http://javaboutique.internet.com/tutorials/stax/
http://today.java.net/pub/a/today/2006/07/20/introduction-to-stax.html
Hope this might be of some help :)
REGARDS,
RaHuL
http://weblogs.java.net/blog/spericas/archive/2006/04/sun_stax_parser.html -
Update column with subquery returning more than one row
Hi Everybody,
Please let me know how to handle this. I am writing update statement in procedure with subquery and it is returning multiple rows. Please help me, how i can handle this :
UPDATE TABLEA A
SET A.ERROR_MESSAGE = (Select B.XERROR_MESSAGE from TABLEB B, TABLEA A WHERE B.id = A.id)
WHERE A.id = (Select B.id from TABLEB B, TABLEA A WHERE B.id = A.id);
(Select B.XERROR_MESSAGE from TABLEB B, TABLEA A WHERE B.id = A.id) --- This subquery is returning more than one rows. How i can handle this in Pl/SQL?
Please let me know. I will be very thankful to you all.
I will really appreciate your replies and comments.
Thank youTry getting rid of tablea in your subqueries. You already have it in the UPDATE statement.
UPDATE TABLEA A
SET A.ERROR_MESSAGE = (Select B.XERROR_MESSAGE
from TABLEB B
WHERE B.id = A.id
WHERE A.id = (Select B.id
from TABLEB B
WHERE B.id = A.id);You can also try a simple MERGE:
merge into tablea a
using tableb b
on (a.id = b.id)
when matched then update
set a.error_message = b.xerror_message; -
hi, I just returned from the Apple Store in Larkspur CA and paired my wireless mouse with one of their computers, but it's won't pair with mine at home. Bluetooth is on and it recognizes the wireless keyboard, see's the wireless mouse but won't pair.
While you are waiting for the new charger, go ahead and reset you SMC:
http://support.apple.com/kb/HT1411 -
When I use Adobe Digital Editions 2.0 to return a library book I get the following message, "If this borrowed item was fulfilled with one or more other items, returning it would also return all of these items". What does this message mean?
Might want to have your MacBook looked at.
-
Still problem with single-row subquery returns more than one row
//i did join each table but query runs forever and fail. looks Cartesian join so comes up the following SQL
the following query has a problem. would you please help me, please
Select pe.expense_id
,PE.CODE
,PE.PROJECT_ID
,PE.LDATE
,PE.INAMOUNT pe_amount
,(SELECT TRX.INV_AMOUNT FROM TRXEXPENSES TRX
WHERE PE.EXPENSE_ID=TRX.EXPENSE_ID) AS invamount
,(SELECT RE.AMOUNT FROM REEXPENSES RE WHERE
PE.EXPENSE_ID=RE.EXPENSE_ID) AS recogamount
,(SELECT MLE.M_AMOUNT FROM MATEXPENSES MLE
WHERE PE.EXPENSE_ID=MLE.EXPENSE_ID) AS matamount
from EXPENSES PE
where pe.expense_id=5600
group by expense_id,CODE,PROJECT_ID,LDATE,inamount
//get error message
ora-01427:single-row subquery returns more than one row
//check database
select expense_id,count(*) from TRXEXPENSES
where expense_id in(select expense_id from
expenses)
group by expense_id
having count(*)>1
//here is duplicate record a lot
EXPENSE_ID COUNT(*)
4176 2
5600 3
9572 2
9573 2
9574 2Yes, Expense_id has so many returning rows for trx.inv_amount from trxexpenses in subquery.
I want to show Expense_id with retruning rows using the above query.
ex)The result of the query is like that;
Expense_ Id project_id Ldate InvAmount RecogAmount MatAmount
5600 123 3/2/02 $100(InvAmount)
5600 432 3/12/02 $200(recogAmount)
5600 432 4/12/02 $250(MatAmount)
Thank you so much
Message was edited by:
user524064
Message was edited by:
user524064 -
Problems with JSP Documents (XML Mode)
Hi --
Have been following the spec for JSP as XML documents because I want to produce JSPs using XSLT. Two problems which I've yet to find anything but workarounds for:
1. (Most pressing) JSP Documents do not allow this <%= blah %>. This creates problems when I want to dynamically create an attribute value. The spec recommends this: 'value = "%=var%"', but I've tried this in Tomcat 4.1.12 and the expression gets reproduced literally at run-time. I've searched these forums and not found an answer.
2. Transformer wigs out on colons in "jsp:root" or "c:out" because it signifies a namespace with which it is unfamiliar. It doesn't need to recognize the namespace. Right now I'm putting in placeholders (jsp999root, for example) and replacing them after processing. Is there a better way?
These problems are really getting in the way. Any help would be most appreciated.Have been following the spec for JSP as XML documents because I want to
produce JSPs using XSLT. Two problems which I've yet to find anything but
workarounds for:
1. (Most pressing) JSP Documents do not allow this <%= blah %>. This creates
problems when I want to dynamically create an attribute value. The spec
recommends this: 'value = "%=var%"', but I've tried this in Tomcat 4.1.12 and
the expression gets reproduced literally at run-time. I've searched these
forums and not found an answer. I am stuck on this also and desperately searching for an answer. Has anyone found anything yet?
2. Transformer wigs out on colons in "jsp:root" or "c:out" because it
signifies a namespace with which it is unfamiliar. It doesn't need to
recognize the namespace. Right now I'm putting in placeholders (jsp999root,
for example) and replacing them after processing. Is there a better way?You can (and should) put multiple namespace declarations in the xsl:stylesheet tag. that will let it know about jsp:* and pass it through appropriately. Try something like:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:jsp="http://java.sun.com/JSP/Page"> -
Validation of XML with Schema, which contains more than one Schema
Hi All,
I am having a parent.xsd file, which inculdes or imports child.xsd file. I need to validate an xml with the parent xsd. Could u give any sample code for doing the same.
Java Version : 1.4.2
Using Xerces for parsing the xml....
Thanks,
SenthilIs anyone there to reply?
-
Returning XML Data from a database
Ok, just got the new DW CS3 and really want to begin using
the built in Spry capabilitites. All of the examples I've seen for
populating the datasets with XML data are based on referencing a
static XML file. I want to query my database and return XML data to
a Spry Table. How do I accomplish this? I know how to perform the
query and retrun the data in an XML format (ColdFusion) but I can't
tell the spry dataset to use this. HELP!!Well, that's the trick... I can't point to a testing server
(i.e. Application interface) because we aren't permitted to have
the RDS login where I work. (They haven't bothered to configure the
CF server for restricting access) I have to manually create all
connections and queries. I'm currenlty using the exact format in
the example page you provided to return the data in an XML format
but when I point to that file as my datasource I get nothing
displayed on the page. The file that performs the query and returns
the data is in a separate file from the one I'm trying to use the
Spry table in. When I use this same query file for an Ajax call to,
say, populate a listbox or pulldown menu it works fine, but I can't
get it to work with the Spry dataset. -
Get a table from XML with unknown number of columns
Guys, I'm looking if it is possible to get the following result:
imagine I have an XML like one of the following (it doesn't matter which one, I just give a few examples for you to have a choice). The main idea, that there are described several columns and values for 1 row of these columns, e.g.:
SQL> with t as (select
2 ' <column>
3 <name>col1</name>
4 <value>100</value>
5 </column>
6 <column>
7 <name>col2</name>
8 <value>200</value>
9 </column>' xml from dual union all
10 select
11 ' <column>col1
12 <value>100</value>
13 </column>
14 <column>col1
15 <value>100</value>
16 </column>' from dual union all
17 select
18 '<col1>100</col1>
19 <col2>200</col2>' from dual)
20 --
21 select * from t
22 /
XML
<column>
<name>col1</name>
<value>100</value>
</column>
<column>
<name>col2</name>
<value>200</value>
</column>
<column>col1
<value>100</value>
</column>
<column>col1
<value>100</value>
</column>
<col1>100</col1>
<col2>200</col2>
SQL> I want to get the following result from this XML:
COL1 COL2
100 200So the main idea here is that the number of columns can vary - it is not fixed.
So it is quite similar to dynamic SQL.
Is it possibe with XML?The only general way to get a flexible amount of columns I know of is to use table functions returning anydataset.
It should be rather straightforward to pass in a xml document and return its tablestructure respectivly (though the »structure« of the xml must be fixed).
Would that be an acceptable way of doing this? -
Parsing XML with namespaces SOLVED
I'm working on a SOAP-based self-service UCCX/IPIVR script where the caller inputs an account number and I call a SOAP service and get an XML result. That part works great. I used this excellent article https://supportforums.cisco.com/document/97736/uccx-8x-really-simple-soap-client-no-custom-jar to accomplish that. With slight modification to work with the particular server/service, it works flawlessly.
My return XML file has namespaces in it with multiple sections. See attached text file with the return results.I get the same result from the SOAP call from UCCX and also from SoapUI.
First off, my Java skills are very basic at best. Also, please forgive me if I use incorrect terms when it comes to XML nomenclature.
I need to read each <b:Bill> section and parse the various elements within each section. I can use the statement "//*[local-name()='AssessmentType']" and get the AssessmentType element from the 1st <b:Bill> section but that's it. I don't know how to access the 2nd and subsequent <b:Bill> sections. I checked a number of different articles on various sites including the forums but I haven't found anything that I can understand let alone make work. I thought using QName was going to be my answer but I can't figure out how to make that work.The more I read about this the more confused I get.
I found a reference somewhere using //Bills/Bill[1]/AssessmentType to access the 1st section and //Bills/Bill[2]/AssessmentType to access the 2nd section but that returns null in both instances. If I use //a:Bills/b:Bill/b:AssessmentType I get an exception, prefix must resolve to a namespace a: exception in org.Apache.xpath.domapi.XPathStylesheetDOM3Exception.
I event tried modifying the <b:Bill> tag to <b:Bill ID="1"> and using "//*[local-name()=[@ID=1]/AssessmentType" and <Bill ID="1"> but neither of those worked. I tried removing the b: from all of the elements and tried using the same syntax but I still get null.
I'm hoping someone can point me in the right direction on how I can do what I need to do, if it's even possible. I'm sure it is, I just don't know how to go about it.
For testing, I just hard-coded the return XML string into a String variable, converted that to a document so I could use the Get XML Document Data step to parse it. The soapResponseStringModified variable is:
U"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><SOAPGetBillSummaryResponse xmlns=\"http://soap.xxx\"><SOAPGetBillSummaryResult xmlns:a=\"http://schemas.xxx\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\"><a:ErrorMessage i:nil=\"true\"/><a:Success>true</a:Success><a:BillCount>2</a:BillCount><a:Bills xmlns:b=\"http://schemas.xxx\"><b:Bill><b:AssessmentType>Annual</b:AssessmentType><b:BillAmount>8259.96</b:BillAmount><b:BillNumber>272818</b:BillNumber><b:BillType>Secured</b:BillType><b:IsRollover>False</b:IsRollover><b:LevyAmount>7508.24</b:LevyAmount><b:RollDate>2014</b:RollDate><b:TaxStatus>Cancelled</b:TaxStatus></b:Bill><b:Bill><b:AssessmentType>Additional</b:AssessmentType><b:BillAmount>7758.24</b:BillAmount><b:BillNumber>501340</b:BillNumber><b:BillType>Secured</b:BillType><b:IsRollover>False</b:IsRollover><b:LevyAmount>7758.24</b:LevyAmount><b:RollDate>2014</b:RollDate><b:TaxStatus>Unpaid</b:TaxStatus></b:Bill></a:Bills><a:GlobalData xmlns:b=\"http://schemas.xxx\"><b:Address>123 MAIN ST</b:Address><b:City>ANY TOWN</b:City><b:EDO>19500909</b:EDO><b:IsDelinquent>true</b:IsDelinquent><b:IsVoid>false</b:IsVoid><b:ParcelNumber>00000</b:ParcelNumber><b:State>XX</b:State><b:TaxRateArea>3016</b:TaxRateArea><b:TodaysDate>20150323</b:TodaysDate><b:Zip>00000</b:Zip></a:GlobalData><a:MainRoll>false</a:MainRoll></SOAPGetBillSummaryResult></SOAPGetBillSummaryResponse></s:Body></s:Envelope>"
Script (run in single-step mode from the IDE):
I appreciate any guidance.
BillIt looks like I found a solution to my problem. I haven't explored this for all the possible SOAP methods I have to use but this "solution" looks encouraging.
If I do a replace() on the namespaces for a: and b: with an empty string, then replace the a:, /a:, b: and /b: with an empty string, I can use the XPath statements //Bill[1]/<FieldName>, //Bill[2]/<FieldName>, //Bill[x]/<FieldName> I can extract the data in a loop since I know the total number of bills ahead of time.
I replace xmlns:a="http://schemas.xxx" and xmlns:b="http://schemas.xxx" with "", I can extract the elements in the Bill tags.
It looks like this will solve my problem. It's not elegant but it works. When I loop through the elements, they' re updating appropriately based on the returned XML response.
I'm sure there's a more elegant way to solve this problem but based on my limited coding skills, I found this a workable solution. I don't know how to use all the various Java tools available to me so this does the job.
If someone knows the proper way to do this, I'd like to know how it's done. This will add to my toolkit and make my code easier to maintain down the road.
Bill
Maybe you are looking for
-
Failed attempt at printing .txt file
I've searched high and low for a solution, but I have just had no luck getting any output. I have a function that reads a text file and sends the file to the printer.. however, it never reaches the printer, rather, it just sits and hangs in the print
-
Error message: when downloading data from 2nd display tag table
I am using disaply tag to display data in jsp page. I am using three different section to display the data with three display tag table. The data is displaying correctlly. The display tag downlod excel sheet is working for first display tag table. Wh
-
Why is Johnny Cash under the C's in the music section on my iTunes?
Instead of Johnny Cash being under the J's in iTunes, it's under the C's. When I type Johnny Cash in the search bar, the only artist that comes up is Johnny Cash & June Carter, which I have as a different artist entirely. Johnny Cash, solo, doesn't e
-
How to generate columnar PDM for HANA?
Hi Folks, I'm quite new to PowerDesigner and have been working on generating a HANA database from MS SQLServer. Currently I've been able to import a source SQLServer system as a Physical Data Model in PowerDesigner. I was then able to generate SQL DD
-
Error Code: U44M1P7 in trying to update CS6 and Bridge. ?? Please help