Element casting problem in XML
I'm having trouble reading an XML document.. When I have a NodeList and get its childnodes with the method getChildNodes(), the resulting NodeList is unable to cast items to Element using the item()-method. If I try to read a certain group of elements using getElementsByTagName() the NodeList casts items to Element just fine. What am I doing wrong? Am I perhaps using the wrong method? I have posted an example below:
This listing works just fine:
Element element = (Element) nodes.item(0);
NodeList innerNodeList = element.getElementsByTagName("spot");
Element element1 = (Element) innerNodeList.item(0);
While this one throws "Exception in thread "Thread-2" java.lang.ClassCastException: com.sun.org.apache.xerces.internal.dom.DeferredTextImpl":
Element element = (Element) nodes.item(0);
NodeList innerNodeList = element.getChildNodes();
Element element1 = (Element) innerNodeList.item(0);
While this one throws "Exception in thread "Thread-2"
java.lang.ClassCastException:
com.sun.org.apache.xerces.internal.dom.DeferredTextImpl
Element element = (Element) nodes.item(0);
NodeList innerNodeList = element.getChildNodes();
Element element1 = (Element) innerNodeList.item(0);The NodeList returned by getChildNodes contains all children of the element including text nodes.
I.e. consider the following xml:<td>some text<p>more text</p>yet more text</td>The td element will have three children: a text node representing "some text", an element node for the p element, and a text node representing "yet more text".
The good thing is that all objects in a NodeList are instances of org.w3c.Node, so you can use its getNodeType method to determine its type and then use the appropriate cast:Element element = (Element) nodes.item(0);
NodeList innerNodeList = element.getChildNodes();
Element element1;
if (innerNodeList.item(0).getNodeType() == Node.ELEMENT_NODE)
element1 = (Element) innerNodeList.item(0);
}Usually you will end up with code like this:private void handleNodes( NodeList nl )
final int length = nl.getLength();
for ( int k = 0; k < length; ++k )
final Node node = nl.item( k );
switch ( node.getNodeType() )
case Node.ELEMENT_NODE:
handleElement( (Element)node );
break;
case Node.TEXT_NODE:
handleText( (Text)node );
break;
default:
// ignore all other node types
}
Similar Messages
-
Problems with the xsl element ---- xsl:output method="xml"/ ----
Hy, my problem is the next, I am trying to read a xml file and transform it in itself but when I do with XSLT, Internet Explorer doesnt show a xml file, just show me the text nodes of the xml file. I have the element <xsl:output method="xml"/>" in the xsl file but I dont Know what Iam doing wrong.
The next code is from the xsl file:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:copy-of select="catalog"/>
</xsl:template>
</xsl:stylesheet>
The next code is from the xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Edited with XML Spy v2007 (http://www.altova.com) -->
<?xml-stylesheet type="text/xsl" href="PlantillaXSL.xml"?>
<catalog dni="4546545">
<cd numero="2" id="5" color="red">
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
</catalog>
The result in internet explorer is:
Bob Dylan USA Columbia 10.90 1985All right. I asked because it's unusual to use the ".xml" extension for an XSL file, so I thought it might be an error. But there's nothing wrong with that.
Next debugging step: is that XSL file actually being used? Insert some debugging code in it so that you can tell. -
Interconnect 10g problem with XML which has mixed contents
I'm having problem to receive a XML message which contains PCDATA and other child element Mixed. Here is the sample DTD. I'm able to create the CV and AV by importing this DTD. But at runtime, if the inbound XML contains PCDATA and other element mixed, it throws error. Any help/ workaround will be appreciated.
<!ELEMENT VIEW_TRAN_M3 (#PCDATA | PERSON_ID | MP_CODE | STARTDATE | ENDDATE)* >
<!ELEMENT PERSON_ID ( #PCDATA ) >
<!ELEMENT MP_CODE ( #PCDATA ) >
<!ELEMENT STARTDATE ( #PCDATA ) >
<!ELEMENT ENDDATE ( #PCDATA ) >
Sample XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE MEALPLAN>
<VIEW_TRAN_M3>
ABC123
<PERSON_ID>12345</PERSON_ID>
<MP_CODE>1</MP_CODE>
</VIEW_TRAN_M3>
Thx
SaumitraPatch Number: 4901802 will fix this problem. Please look at SR Number 4960460.992 for more details.
-
Problem parsing XML with schema when extracted from a jar file
I am having a problem parsing XML with a schema, both of which are extracted from a jar file. I am using using ZipFile to get InputStream objects for the appropriate ZipEntry objects in the jar file. My XML is encrypted so I decrypt it to a temporary file. I am then attempting to parse the temporary file with the schema using DocumentBuilder.parse.
I get the following exception:
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element '<root element name>'
This was all working OK before I jarred everything (i.e. when I was using standalone files, rather than InputStreams retrieved from a jar).
I have output the retrieved XML to a file and compared it with my original source and they are identical.
I am baffled because the nature of the exception suggests that the schema has been read and parsed correctly but the XML file is not parsing against the schema.
Any suggestions?
The code is as follows:
public void open(File input) throws IOException, CSLXMLException {
InputStream schema = ZipFileHandler.getResourceAsStream("<jar file name>", "<schema resource name>");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
try {
factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
factory.setAttribute(JAXP_SCHEMA_SOURCE, schema);
builder = factory.newDocumentBuilder();
builder.setErrorHandler(new CSLXMLParseHandler());
} catch (Exception builderException) {
throw new CSLXMLException("Error setting up SAX: " + builderException.toString());
Document document = null;
try {
document = builder.parse(input);
} catch (SAXException parseException) {
throw new CSLXMLException(parseException.toString());
}I was originally using getSystemResource, which worked fine until I jarred the application. The problem appears to be that resources returned from a jar file cannot be used in the same way as resources returned directly from the file system. You have to use the ZipFile class (or its JarFile subclass) to locate the ZipEntry in the jar file and then use ZipFile.getInputStream(ZipEntry) to convert this to an InputStream. I have seen example code where an InputStream is used for the JAXP_SCHEMA_SOURCE attribute but, for some reason, this did not work with the InputStream returned by ZipFile.getInputStream. Like you, I have also seen examples that use a URL but they appear to be URL's that point to a file not URL's that point to an entry in a jar file.
Maybe there is another way around this but writing to a file works and I set use File.deleteOnExit() to ensure things are tidied afterwards. -
How to retrieve elements from 3 different xml file in one url
Hi all,
Could anyone please let me how can we retrieve elements from 3 different xml file in one url?
i just can only do it with one file only, any help would very appreciate.
Thank in advance
JimHi Philip
Thanks for replying me.
I tried on that way, In my mdx query i am using one slice attribute (i.e [Customer].[Gender].allmembers) in rows so getting error "The Hierarchy already appears in Axis1".
SELECT
{[Measures].[Internet Sales Amount] } ON 0,
NON EMPTY
{[Customer].[Gender].allmembers } ON 1 -- Used
FROM
[Adventure Works]
WHERE
[Customer].[Gender].&[M]
,[Product].[Size Range].[(All)]
,[Customer].[Country].[All Customers]
[Customer].[Gender].[All Customers]
,[Product].[Size Range].&[XL]
,[Customer].[Country].[All Customers]
[Customer].[Gender].[All Customers]
,[Product].[Size Range].[(All)]
,[Customer].[Country].&[Australia]
Can you provide alternate ways to get resolved.
Thanks in advance -
hi everybody,
I've a big problem with XML on Linux, in details I see my program stopping on Linux at the instruction
XMLReader xr = XMLReaderFactory.createXMLReader("org.apache.crimson.parser.XMLReaderImpl");
and it's strange because on Windows it runs and there aren't problems about permissions on files, does anyone knows what to do?
thanks in advance!
StefanoWhat happens on that line? I'm assuming you get some kind of error or exception.
Make sure the JAR file for Crimson is in your classpath. -
Problem with XML in APEX ORA-06502
i, I have a problem with XML generation, I developed an application in APEX, and in a html page I have this process:
declare
l_XML varchar2(32767);
begin
select xmlElement
"iva",
xmlElement("numeroRuc",J.RUC),
xmlElement("razonSocial", J.RAZON_SOCIAL),
xmlElement("idRepre", J.ID_REPRE),
xmlElement("rucContador", J.RUC_CONTADOR),
xmlElement("anio", J.ANIO),
xmlElement("mes", J.MES),
xmlElement
"compras",
select xmlAgg
xmlElement
"detalleCompra",
--xmlAttributes(K.ID_COMPRA as "COMPRA"),
xmlForest
K.COD_SUSTENTO as "codSustento",
K.TPLD_PROV as "tpldProv",
K.ID_PROV as "idProv",
K.TIPO_COMPROBANTE as "tipoComprobante",
to_char(K.FECHA_REGISTRO, 'DD/MM/YYYY') as "fechaRegistro",
K.ESTABLECIMIENTO as "establecimiento",
K.PUNTO_EMISION as "puntoEmision",
K.SECUENCIAL as "secuencial",
to_char(K.FECHA_EMISION, 'DD/MM/YYYY') as "fechaEmision",
K.AUTORIZACION as "autorizacion",
to_char(K.BASE_NO_GRA_IVA, 9999999999.99) as "baseNoGraIva",
to_char(K.BASE_IMPONIBLE, 9999999999.99) as "baseImponible",
to_char(K.BASE_IMP_GRAV, 9999999999.99) as "baseImpGrav",
to_char(K.MONTO_ICE, 9999999999.99) as "montoIce",
to_char(K.MONTO_IVA, 9999999999.99) as "montoIva",
to_char(K.VALOR_RET_BIENES, 9999999999.99) as "valorRetBienes",
to_char(K.VALOR_RET_SERVICIOS, 9999999999.99) as "valorRetServicios",
to_char(K.VALOR_RET_SERV_100, 9999999999.99) as "valorRetServ100"
xmlElement
"air",
select xmlAgg
xmlElement
"detalleAir",
xmlForest
P.COD_RET_AIR as "codRetAir",
to_char(P.BASE_IMP_AIR, 9999999999.99) as "baseImpAir",
to_char(P.PORCENTAJE_AIR, 999.99) as "porcentajeAir",
to_char(P.VAL_RET_AIR, 9999999999.99) as "valRetAir"
from ANEXO_COMPRAS P
where P.ID_COMPRA = K.ID_COMPRA
AND P.ID_INFORMANTE_XML = K.ID_INFORMANTE_XML
xmlElement("estabRetencion1", K.ESTAB_RETENCION_1),
xmlElement("ptoEmiRetencion1", K.PTO_EMI_RETENCION_1),
xmlElement("secRetencion1", K.SEC_RETENCION_1),
xmlElement("autRetencion1", K.AUT_RETENCION_1),
xmlElement("fechaEmiRet1", to_char(K.FECHA_EMI_RET_1,'DD/MM/YYYY')),
xmlElement("docModificado", K.DOC_MODIFICADO),
xmlElement("estabModificado", K.ESTAB_MODIFICADO),
xmlElement("ptoEmiModificado", K.PTO_EMI_MODIFICADO),
xmlElement("secModificado", K.SEC_MODIFICADO),
xmlElement("autModificado", K.AUT_MODIFICADO)
from SRI_COMPRAS K
WHERE K.ID IS NOT NULL
AND K.ID_INFORMANTE_XML = J.ID_INFORMANTE
AND K.ID BETWEEN 1 AND 25
).getClobVal()
into l_XML
from ANEXO_INFORMANTE J
where J.ID_INFORMANTE =:P3_MES
and J.RUC =:P3_ID_RUC
and J.ANIO =:P3_ANIO
and J.MES =:P3_MES;
--HTML
sys.owa_util.mime_header('text/xml',FALSE);
sys.htp.p('Content-Length: ' || length(l_XML));
sys.owa_util.http_header_close;
sys.htp.print(l_XML);
end;
Now my table has more than 900 rows and only when I specifically selected 25 rows of the table "ANEXO_COMPRAS" in the where ( AND K.ID BETWEEN 1 AND 25) the XML is generated.+
I think that the problem may be the data type declared "varchar2", but I was trying with the data type "CLOB" and the error is the same.+
declare
l_XML CLOB;
begin
--Oculta XML
sys.htp.init;
wwv_flow.g_page_text_generated := true;
wwv_flow.g_unrecoverable_error := true;
--select XML
select xmlElement
from SRI_COMPRAS K
WHERE K.ID IS NOT NULL
AND K.ID_INFORMANTE_XML = J.ID_INFORMANTE
).getClobVal()
into l_XML
from ANEXO_INFORMANTE J
where J.ID_INFORMANTE =:P3_MES
and J.RUC =:P3_ID_RUC
and J.ANIO =:P3_ANIO
and J.MES =:P3_MES;
--HTML
sys.owa_util.mime_header('text/xml',FALSE);
sys.htp.p('Content-Length: ' || length(l_XML));
sys.owa_util.http_header_close;
sys.htp.print(l_XML);
end;
The error generated is ORA-06502: PL/SQL: numeric or value error+_
Please I need your help. I don`t know how to resolve this problem, how to use the data type "CLOB" for the XML can be generate+JohannaCevallos07 wrote:
Now my table has more than 900 rows and only when I specifically selected 25 rows of the table "ANEXO_COMPRAS" in the where ( AND K.ID BETWEEN 1 AND 25) the XML is generated.+
I think that the problem may be the data type declared "varchar2", but I was trying with the data type "CLOB" and the error is the same.+
The error generated is ORA-06502: PL/SQL: numeric or value error+_
Please I need your help. I don`t know how to resolve this problem, how to use the data type "CLOB" for the XML can be generate+The likeliest explanation for this is that length of the XML exceeds 32K, which is the maximum size that <tt>htp.p</tt> can output. A CLOB can store much more than this, so it's necessary to buffer the output as shown in +{message:id=4497571}+
Help us to help you. When you have a problem include as much relevant information as possible upfront. This should include:
<li>Full APEX version
<li>Full DB/version/edition/host OS
<li>Web server architecture (EPG, OHS or APEX listener/host OS)
<li>Browser(s) and version(s) used
<li>Theme
<li>Template(s)
<li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
And always post code wrapped in <tt>\...\</tt> tags, as described in the FAQ.
Thanks -
How to update Elements value inside existing xml file
Hi Gurus,
Am somehow new to java and working on xml with java, i have a scenario where i want to update the elements of my existing xml file, i know its possible as i have posted one code on this forum which updates the values of the arrtibutes of existing xml file. Ref :
http://forum.java.sun.com/thread.jsp?forum=34&thread=186091&start=15&range=15&hilite=false&q=
But am not able to use the same code to update the vlaues of the attribute.
if i have this xml file :
<?xml version="1.0"?>
<RootElement>
<Transaction>
<Task9>
<TaskID>Task9</TaskID>
<Description>My Test Case</Description>
<Time>12/12/2004</Time>
</Task9>
</Transaction>
<Transaction>
<Task2>
<TaskID>Task2</TaskID>
<Description>Testing my xml</Description>
<Time>12/12/2004</Time>
</Task2>
</Transaction>
</RootElemen>
Now i want to update teh </Description> and </Time> field using the code that i have given above in the link.
If any one can help me ill really appreciate.The value of an element is stored in a child node of that element. For example, let's say that "e" references the node <Description> then:
e.getFirstChild().getNodeValue() => "My Test Case" -
Hi
I am working on BLS and having problem in xml query.I want to perform some calculation over xml columns.Than total of this as a new column.I can do this part in logic editor itself but can i do these both task by XSLT.
Can be made our own XSLT for this ?
I am feeling kind of fear to xslt. Can anybody help me in this.
Thanks a lot in advance
thomasRam,
In xMII there is a list of predefined xslt transforms that do something similar to what you are explaining. The 3 that I think may be what you are looking for are
they are under Calculation Transformations and Subtotal Transformation take a look at these and tell me if they are doing what you want to accomplish. In the xMII help file do a search on Inline Transforms or navigate to Advanced Topics -> Inline Transforms -> Predefined Inline Transforms. In this section there are examples of how to use these transforms and apply them in the query templates. If this is not what you are looking for can you explain in a little more detail along with a simple example of how you want this transform to work. Also why do you want to use xslt if you can already accomplish this in BLS?
Regards,
Erik -
Facing problem in xml schema xsd file registration
Hi,
i am facing problem in xml schema xsd file registration when
the number of column is more. It is showing persing error.
if i am deleting few column from xsd file . It is working otherwise
showing error. Is there any solution for that please suggest me.
The Error is
ORA-31011:XML parsing failed
ORA_19202: Error occurred in XML processing
LPX-00230 : (message vary time to time-like invalid tag ending etc.)
Regards
Manoranjan
and thanks in advanceWhere is you XML coming from. Are you sure it's valid. If you are hard coding it as a SQL String constant are you hitting the 4k / 32K limit on the size of SQL / PL/SQL constant. Have you tried loading the content from a bfile..
-
Problem for xml generation using DBMS_XMLGEN
Hi All,
i have problem during xml generation using Any help would be highly appreciate
how could we publish xml data using data base API DBMS_XMLGEN in oracle applications (APPS) i.e. at 'View Output" using
Any help would be highly appreciate.
Let me know if need more explanation, this is High priority for me.
Thanks and Regards,
[email protected]
Message was edited by:
user553699You can set the null attribute to true , so that the tag appears in your XML
see the statement in Bold.
DECLARE
queryCtx dbms_xmlquery.ctxType;
result CLOB;
BEGIN
-- set up the query context
queryCtx := dbms_xmlquery.newContext(
'SELECT empno "EMP_NO"
, ename "NAME"
, deptno "DEPT_NO"
, comm "COMM"
FROM scott.emp
WHERE deptno = :DEPTNO'
dbms_xmlquery.setRowTag(
queryCtx
, 'EMP'
dbms_xmlquery.setRowSetTag(
queryCtx
, 'EMPSET'
DBMS_XMLQUERY.useNullAttributeIndicator(queryCtx,true);
dbms_xmlquery.setBindValue(
queryCtx
, 'DEPTNO'
, 30
result := dbms_xmlquery.getXml(queryCtx);
insert into clobtable values(result);commit;
dbms_xmlquery.closeContext(queryCtx);
END;
select * from clobtable
<?xml version = '1.0'?>
<EMPSET>
<EMP num="1">
<EMP_NO>7499</EMP_NO>
<NAME>ALLEN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>300</COMM>
</EMP>
<EMP num="2">
<EMP_NO>7521</EMP_NO>
<NAME>WARD</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>500</COMM>
</EMP>
<EMP num="3">
<EMP_NO>7654</EMP_NO>
<NAME>MARTIN</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>1400</COMM>
</EMP>
<EMP num="4">
<EMP_NO>7698</EMP_NO>
<NAME>BLAKE</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
<EMP num="5">
<EMP_NO>7844</EMP_NO>
<NAME>TURNER</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM>0</COMM>
</EMP>
<EMP num="6">
<EMP_NO>7900</EMP_NO>
<NAME>JAMES</NAME>
<DEPT_NO>30</DEPT_NO>
<COMM NULL="YES"/>
</EMP>
</EMPSET>
http://sqltech.cl/doc/oracle9i/appdev.901/a89852/d_xmlque.htm -
Ignoring the DOCTYPE element while parsing the xml
I am using JAXB parser to read from and write into my xml file using java code. My xml file contains a DOCTYPE element pointing to a .dtd file which does not exist, due to which I get a FileNotFoundException when JAXB tries to read the xml file. Hence, after unmarshalling the xml file using jaxb, I use a SAXParser to get an XMLReader which removes this DOCTYPE element as given below -
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
parserFactory.setValidating(false);
XMLReader reader = parserFactory.newSAXParser().getXMLReader();
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
After making the required changes to the xml file and marshalling it back, I then use an XMLWriter to add the DOCTYPE element back to the xml file as given in the code snippet below -
SAXReader saxReader = new SAXReader();
Document document = saxReader.read(_file);
document.addDocType(rootElement, publicUri, systemUri);
XMLWriter output = new XMLWriter(new FileWriter( _file ));
output.write( document );
output.close();
Right now I am using both, the JAXB parser to read from and write into the xml file and SAXParser/SAXRader just to delete/add the DOCTYPE element. I want to avoid using two different parsers in my class and want to know if JAXB provides any mechanism to delete and then add this element while parsing the xml file.Standard answer for this FAQ: set an EntityResolver on your parser that sends an empty string instead of the DTD. The API docs have an example that you could modify to do that.
-
XML DevCon 2001: Submit schema and stylesheet problems- win XML Spy
There are only a few days to submit schema and stylesheet problems for XML
DevCon 2001 in London. If the workshop instructors use your submission
during the conference, you win a copy of XML Spy.
<shamelessPlug>
XML DevCon 2001 has a content-rich technical program with a faculty that
includes Henry Thompson (W3C Fellow), Peter Chen (IEEE Fellow, ACM
Fellow),
Martin Bryan (DIFFUSE Project), and authors such as Bob DuCharme, Ian
Graham, Elliotte Rusty Harold, G. Ken Holman, Benoît Marchal, JP
Morgenthal,
and Simon St. Laurent. There are a variety of eBusiness sessions,
including
panel discussions and presentations about ebXML, Web Services, and UDDI.
The program includes presentations by Jonathan Borden, Ron Bourret, Lee
Buck, Alex Chaffee, Mark Colan, John Evdemon, Meike Klettke, Andy
Longshaw,
Ingo Macherius, Simon Nicholson, David Orchard, Sebastian Rahtz, Daniel
Rivers-Moore, Michael Rys, Krishna Sankar, Matt Sergeant, Richard Tobin,
Priscilla Walmsley, David RR Webber and other distinguished faculty.
</shamelessPlug>
http://www.xmldevcon2001.com/London/html/conference.php
For a free pass to exhibits and special events (keynotes, joint XML UK and
British Computer Society meeting, OASIS XPath/XSLT meeting, vendor
presentations):
http://www.xmldevcon2001.com/London/html/special_events.php
Public submissions (schemas and stylesheets)
Three members of the W3C Schema Working Group (Michael Rys, Henry
Thompson, Priscilla Walmsley) will teach a Schema Workshop. Submit
problem schemas to them by e-mail:
[email protected]
or
http://www.xmldevcon2001.com/London/html/session.php?code=W5
Sebastian Rahtz, Bob DuCharme, Benoît Marchal, and Ken Holman will
present the "Stylesheets and Transformations: Best Practices" workshop on
Thursday, February 22 in London. To submit a stylesheet or problem
description for their workshop:
[email protected]
or browse to:
http://www.xmldevcon2001.com/London/html/session.php?code=T17
========== Ken North ======================
See you at Javacon 2001 (New York, March 1)
www.javacon2001.com
XML DevCon 2001: London (February 21-23) New York (April 8-11)
www.xmldevcon2001.com
=======================================Looks okay to me. But then I have no idea of what those "problems" are that you mentioned. Was there a particular reason you didn't tell us what they are?
-
The following code gives me runtime casting problems:
package edu.columbia.law.markup.test;
import java.util.*;
public class A {
protected static Hashtable hash = null;
static {
hash = new Hashtable ();
hash.put ("one", "value 1");
hash.put ("two", "value 2");
public static void main (String args []) {
A a = new A ();
String keys [] = a.keys ();
for (int i = 0; i < keys.length; i++) {
System.out.println (keys );
public String [] keys () {
return (String []) hash.keySet ().toArray ();
The output on my console is:
java.lang.ClassCastException: [Ljava.lang.Object;
at edu.columbia.law.markup.test.A.keys(A.java:37)
at edu.columbia.law.markup.test.A.main(A.java:29)I can not understand why is it a problem for JVM to cast?
Any ideas?
Thanks,
Alex.return (String []) hash.keySet ().toArray ();This form of toArray returns an Object[] reference to an Object[] object. You cannot cast a reference to an Object[] object to a String[] reference for the same reason that you cannot cast a reference to a Object object to a String reference.
You must use the alternate form of toArray instead:
return (String []) hash.keySet ().toArray (new String[0]);This will return an Object[] reference to a String[] object, and this reference can be cast to a String[] reference. -
Map several records to different elements in the same xml node
Hi,
I am trying to map data from relational tables to elements as per my xml schema. One of my tables has several records that I need to map to different elements in the same xml node.
For example:
Customer_Id | Param_Id |Param_Name
212 | 1 |State
212 | 2 |Country
212 | 3 |ZipCode
I can not change the structure of this existing table and need to work with it.
How do I map the different params for a specific customer to my Customer node in the schema?
One option is to join on the parameters table several times, but there ought to be a better way!
PLEASE HELP!!!
Thanks,First I question the design that contains/allows 600 attributes on an element. They sound like they really should be elements in the XML.
Regardless, the following (NOT TESTED) should work for you (assuming you want to write one SQL with 600 columns)
CREATE OR REPLACE VIEW APPLICATION_XML
OF XMLTYPE
Element "LOAN_APPLICATION"
with object ID
substr(extractValue(object_value,'/LOAN_APPLICATION/APPLICATION_DATA/@CallID'),1,5)
AS
WITH parm_tb AS
SELECT MAX(DECODE(prv_valu, 1, prv_value)) BusinessType,
MAX(DECODE(param_id, 2, prv_value)) Product,
MAX(DECODE(param_id, 3, prv_value)) SomethingElse
FROM parameter_details
WHERE prv_pmh_header_id = 1
SELECT xmlElement
("APPLICATION_DATA",
xmlAttributes
p.prv_detail_id as "CallID",
p.PRV_PRM_PARAM_ID as "RandomID",
p.prv_value as AppInitDate
xmlElement
("PRODUCER_DATA",
xmlAttributes
parm_tb.BusinessType as "BusinessType" ,
parm_tb.Product as "Product"
FROM parameters_table p
WHERE p.PRV_PMH_HEADER_ID = 1
Maybe you are looking for
-
How do I use Panorama / Tab Groups with the keyboard?
Yes I know that CTRL-SHIFT-E opens the panorama window, and then I can use the mouse to organize my tabs into groups. But how do I do this with the keyboard? I've [http://lifehacker.com/#!5719596/switch-between-tab-groups-in-firefox-with-a-keyboard-s
-
version. Help! I can't access anything. This all started because I was unable to get my ipod to play via USB in my vehicle.It reccognized it and saw the songs, but wouldn't play. I need to get my library back!
-
Trying to make sense of div tags and css
i know that i am a few years late here, but i am looking ot make the migration from using tables and switching over to div tags and css. i have watched a few tutorials on you tube and am trying to understand everything. please tell me if this is corr
-
How to create contact groups in Jabber for Windows
Attempting to deploy Jabber for Windows. I can't find where in CUPS to build the contact groups that will deploy to the users. We are wanting to build our groups by our locations and deploy them from there. Any help would be greatly appreciated.
-
To watch online requires Microsoft Silverlight! (L...
I know us Linux users are often left out in the cold but come on BT, Silverlight! WTF