JAXB namespace common elements
Hi,
I'm generating a parser according to 3 DTDs:
main.dtd
devinf.dtd
metinf.dtd
I have translated the DTDs in 3 XML schemas with DTD to XML Schema translator (found on w3c) that Translate a Document Type Definition (XML 1.0 DTD) into an XML schema (REC-xmlschema-1-20010502):
http://puvogel.informatik.med.uni-giessen.de/dtd2xs/
The main.dtd contains an element Meta defined such as:
<!-- Meta element type -->
<!-- Element types in the content MUST have name space declared. -->
<!--The Meta content would be something such as:
<Meta>
<Type xmlns='metinf'>myType</Type>
<Format xmlns='metinf'>myFormat</Format>
</Meta>-->
<!ELEMENT Meta (#PCDATA)>
AND 2 elements Format and Type!!!!
Converting to Schema:
<xs:element name="Meta" type="xs:string" />
<xs:element name="Format" type="xs:string" />
<xs:element name="Type" type="xs:string" />
The metinf DTD defines the elements Type and Format such as after converting in schema we have:
<xs:element name="Format" type="xs:string" />
<xs:element name="Type" type="xs:string" />
The devinf DTD defines also these two elements !!!!
I tried to modify the main schema to import the devinf and metinf schema. However when I try to compile, I receive the error that the compiler atempts to generates the same interface (Format and Type) from the 3 different schema.
(compile line is:
xjc -jar %JAVA_LIBS%\jaxb-xjc.jar -p mypackage devinf.xsl metinf.xsl main.xsl)
How could I do to obtain a Parser that could read and write the following XML:
<!-- These Format and Type refer to main.dtd -->
<Format>formatA</Format>
<Type>typeA</Type>
<Meta>
<!-- These Format and Type refer to metinf.dtd -->
<Format xmlns="metinf">formatB</Format>
<Type xmlns="metinf">typeB</Type>
</Meta>
<!-- These Format and Type refer to devinf.dtd -->
<Format xmlns="devinf">formatC</Format>
<Type xmlns="metinf">typeC</Type>
Many thanks and sorry for my poor english!
Sorry to disturb you....
Sometimes you found you are really stupid.
The solution for the above problem is to define a custom binding (specifying per example a different package for the different DTDs)
Sorry again
Tanguy
Similar Messages
-
Adding namespace qualified element nodes
Is there a way to add namespace qualified element nodes to
a document stored in a BDBXML container using the XmlModify class
(BDBXML version 2.3.10, Linux)? Or, for that matter, any other
handles?
Particularly, is it possible to achieve this using the PHP
extension?
Let me give an example.
When doing queries, you can set a namespace in the XmlQueryContext
or in the XQuery expression itself:
# prefix cannot be '' as of BDBXML 2.3.10
$qc->setnamespace('a', 'http://as-guides.com/wev1');
declare namespace a = "http://as-guides.com/wev1"; ...
declare default element namespace "http://as-guides.com/wev1"; ...
You can then refer to your namespace qualified elements as "a:Bla"
etc. Or just as "Bla" if you make your namespace the default
namespace.
So far, so good.
Now what if I want to add a namespace qualified element to
my document? However I go about setting the namespace I always end
up with either an apparently namespace qualified element which the
namespace is not registered for or an element in the empty
namespace.
What I want is my element to adhere to the namespace
"http://as-guides.com/wev1", which is set as the default
element namespace in my document.
Here is an example document.
<Broadcast xmlns="http://as-guides.com/wev1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://as-guides.com/wev1 ds.xsd">
<Start epoch="1186100400">2007-08-03T00:20:00Z</Start>
<End epoch="1186100700">2007-08-03T00:25:00Z</End>
<Content>
<Title>Tagesschau</Title>
<Genre>Nachrichten</Genre>
</Content>
</Broadcast>
And here is my PHP code.
$docname = '2007-08-02-1186100400-25758173-ard.xml_41368';
$mgr = new xmlmanager;
$cont = $mgr->opencontainer($argv[1]);
$cont->addalias('tv');
$qc = $mgr->createquerycontext();
$qc->setnamespace('a', 'http://as-guides.com/wev1');
$qexp = $mgr->prepare('/a:Broadcast', $qc);
$mod = $mgr->createmodify();
$mod->addappendstep($qexp, XmlModify_Element, 'a:now', time());
$doc = $cont->getdocument($docname);
$docval = new xmlvalue($doc);
echo $docval->asString(), "\n";
$uc = $mgr->createupdatecontext();
$mod->execute($docval, $qc, $uc);
Here is what gets added as last child node under "Broadcast":
<a:now xmlns="">1189605065</a:now>
So the namespace prefix I specified is added verbatim, without
regard to the namespace settings in $qc (XmlQueryContext) - which
do work fine for the query. No namespace declaration for "a"
is added to the document. The resulting XML is invalid, as
xmllint correctly points out.
namespace error : Namespace prefix a on now is not defined
So settings in XmlQueryContext do not seem to have any bearing on
my update. XmlUpdateContext, on the other hand, does not have any
methods defined for setting the namespace.
Not setting the namespace in $qc (XmlQueryContext) and specifying
it in the XQuery itself didn't work either. I left out the call to
"setnamespace()" and changed the query to:
declare default element namespace "http://as-guides.com/wev1";
/Broadcast
And I changed "a:now" to just "now". Here is what got added:
<now xmlns="">1189607498</now>
I didn't expect this second version to work, but I did expect the first
one to work.
What is the meaning of supplying XmlQueryContext to the execute()
method?
Is there a way to add namespace qualified elements to a document?
If so, how can it be done?Thanks for your answer, George. I haven't quite understood how to make it do the trick, though.
To change one document I did:
dbxml> open tv.dbxml
dbxml> setnamespace a http://as-guides.com/wev1
Binding a -> http://as-guides.com/wev1
dbxml> getdoc 2007-08-02-1186104300-25758380-sat1.xml_40564
1 documents found
dbxml> print
<?xml version="1.0" encoding="UTF-8"?>
<Broadcast xmlns="http://as-guides.com/wev1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://as-guides.com/wev1 ds.xsd">
<Start epoch="1186104300">2007-08-03T01:25:00Z</Start>
<End epoch="1186105800">2007-08-03T01:50:00Z</End>
<VPS>03:25</VPS>
<Content>
<Title>Moin</Title>
</Content>
</Broadcast>
dbxml> append doc(2007-08-02-1186104300-25758380-sat1.xml_40564)/a:Broadcast element "" "<a:now xmlns:a='http://as-guides.com/wev1'>NOW</a:now>"
Appending into nodes: doc(2007-08-02-1186104300-25758380-sat1.xml_40564)/a:Broadcast an object of type: element with name: and content: <a:now xmlns:a='http://as-guides.com/wev1'>NOW</a:now>
0 modifications made.
No change made to my document. I used the doc() function instead of collection() as in the example you gave. Using collection() as in your example (verbatim) I get an error message:
stdin:17: append failed, Error: XmlModify::execute: Cannot perform a modification on an XmlValue that isn't either Node or Document type
This is in the FAQ, but I don't quite get it.
http://www.oracle.com/technology/products/berkeley-db/faq/xml_faq.html#49
Anyway, I can still perform modifications outside of the container and then replace the document. Or wait till 2.4.
Thanks for your answer and the good work. Regards,
Michael -
Define namespaces at element level
hi,
Is it possible to define namespaces at element level. Consider the Below xml file, for which i have to generate a single XSD( not seperate XSD for every namespace)
<sap:Envelope xmlns:sap="urn:sap-com:document:sap" version="1.0">
<sap:Header xmlns:rfcprop="urn:sap-com:document:sap:rfc:properties">
<saptr:From xmlns:saptr="urn:sap-com:document:sap:transport">SAPXX</saptr:From>
<saptr:To xmlns:saptr="urn:sap-com:document:sap:transport">SAPYY</saptr:To>
</sap:Header>
<sap:Body>
<rfc:ZINSERT xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
<CARRID></CARRID>
<CONNID></CONNID>
<FLDATE></FLDATE>
</rfc:ZINSERT>
</sap:Body>
</sap:Envelope>
Regards,
Siva MarananiHi Siva,
I fear there is no chance. The XSD specification requires to build one separate schema document for each namespace used. If you need to have all information in one document you can create a WSDL document that contains several schemas in its types-section.
However, then you would need to make use of the WSDL standard which is build on top of the XSD standard.
Greetings Stephan -
Hello and good day,
I have found dozens of articles on how to remove the uncommon items from a series of near identical photos, for instance removing tourists from a series of shots using Scripts -> Statistics...
What I am trying to do is the exact opposite of this.
I would like to compare a series of frames, and remove all common elements from them; leaving only differences. I figured I would be able to use the statistics script to get the common background, then somehow compare it to each frame and remove the common background. Basically doing a reverse green screen when I am removing the background instead of adding it.
I have Adobe Master Collection CS6.
Regards,
Jeffrey TaylorThat sounds like something AstroPhotographers might use. We have an expert here, but I believe he is kind of busy right now, but he might happen along.
Otherwise, I don't know how to do a reverse Median effect. You can do it with two layers by aligning and setting the top layer blend mode to Difference, but identical features go black. You'd have to make a luminosity mask from that frame and apply it to a layer mask to leave the people after returning the layer mode to normal. But I can't think how to do it with a lot of frames together. -
I was able to solve the unexpected root element error by including the namespace in the xml. Is there a way to configure JAXB to work with or without the namespace?
Here is an excerpt from the top level schema: Is there anything here that would require the use of a namespace?
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 2 U (http://www.xmlspy.com) by Salim Djaffar (WaMu) -->
<xs:schema targetNamespace="http://schema.wamu.com/wamuhomeloans/loan/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:crm="http://schema.wamu.com/crm/customer/" xmlns="http://schema.wamu.com/wamuhomeloans/loan/" elementFormDefault="unqualified" attributeFormDefault="unqualified" version="2.6">
<xs:include schemaLocation="loantypes.xsd"/>
<xs:import namespace="http://schema.wamu.com/crm/customer/" schemaLocation="crmtypes.xsd"/>
<xs:element name="NoteHistoryRequest" type="NoteHistoryRequestType"/>
<xs:element name="NoteHistoryResponse" type="NoteHistoryResponseType"/>
<xs:complexType name="NoteHistoryRequestType">
<xs:sequence>
<xs:element name="LoanInformation" type="LoanInformationType" minOccurs="0"/>
<xs:element name="ListFilter" type="ListFilterType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema> -
Hi,
can anyone tell me what's going wrong.
XML-Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="journal">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item" maxOccurs="unbounded" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>XML-Document to used by JAXB:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:journal xmlns:ns0="a-namespace">
<item>String1</item>
<item>String2</item>
</ns0:journal>The classes were generated by xjc (jwsdp-1.1).
Executing a very simple unmarshalling test throws:
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: unexpected root element ns0:journal]
...thank's for your help
-chrisDeepak,
thanks a lot. Finally I got it with this XML-Schema:
<xsd:schema attributeFormDefault="unqualified"
targetNamespace="a-namespace"
xmlns="a-namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
jxb:version="1.0">
<xsd:annotation>
<xsd:appinfo>
<jxb:globalBindings bindingStyle="elementBinding"
choiceContentProperty="false"
collectionType="java.util.Vector"
enableFailFastCheck="false"
fixedAttributeAsConstantProperty="true"
generateIsSetMethod="false"
typesafeEnumBase="xsd:NCName"
typesafeEnumMemberName="generateError"
underscoreBinding="asCharInWord"/>
<jxb:schemaBindings>
<jxb:package name="package.name"/>
</jxb:schemaBindings>
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="journal" type="journalType" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
<xsd:complexType name="journalType" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="a-namespace">
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="unbounded" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:schema> -
How to parse an XMl without using prefix in the namespace and elements?
Hi
The following is a sample of the xml that I need to parse.
Without the prefix in the namespace section I am getting an error but when i just put in the prefix it works fine. Any help here would be greatly appreciated.
I think i need to change something in the parser set up...may be the somewhere in the bolded lines....but i am clueless...
//Xml begins
<?xml version="1.0" encoding="utf-8" ?>
- <Statemessages xsi:schemaLocation="http://www.SomeLocation.com/SomeXSD.xsd" xmlns="http://www.abcd.com/BSN" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <FileControl>
<CreationDate>2008-08-11</CreationDate>
- <Source>
<SystemID>SAP4BSN</SystemID>
<MandantID>100</MandantID>
</Source>
- <Destination>
<SystemID>CWL</SystemID>
<MandantID>746</MandantID>
</Destination>
<SequenceNumber>000000004</SequenceNumber>
<Counter>000000001</Counter>
</FileControl>
- <Message>
- <PartyRegistrationID>
<ID>2101576347</ID>
<Type>RG</Type>
<ID>2101576347</ID>
<Type>AG</Type>
</PartyRegistrationID>
<CustomerGroupID>02</CustomerGroupID>
<Name>Lewicki</Name>
<Subname>Hans Bruno Michel</Subname>
<DateTime>2008-08-11T23:59:59</DateTime>
- <DefaultOfPayment>
<MessageID>00000001</MessageID>
<GrossAmountBefore>0.0</GrossAmountBefore>
<GrossAmountCurrent>-17.9</GrossAmountCurrent>
<Currency>EUR</Currency>
<SettlementOfBalance>Nein</SettlementOfBalance>
<IncludingSubsidiaryClaim>Ja</IncludingSubsidiaryClaim>
</DefaultOfPayment>
- <ContractsWithDefaultOfPayment>
<ContractID>0148863732</ContractID>
</ContractsWithDefaultOfPayment>
- <Messagedetails>
- <ReturnDebitNote>
<MessageID>00000002</MessageID>
<KindOf>BA</KindOf>
<Reason>E2</Reason>
<Date>2008-08-11</Date>
<GrossAmount>-15.4</GrossAmount>
<Currency>EUR</Currency>
</ReturnDebitNote>
</Messagedetails>
</Message>
</Statemessages>
//XML end
I am using the following stored procedure to try this;
create or replace PROCEDURE CompleteSaveXML_1 AS
XMLMessage2 XMLTYPE;
v_parser dbms_xmlparser.Parser;
v_clob CLOB;
v_sent DATE;
v_doc xmldom.DOMDocument;
v_nl xmldom.DOMNodeList;
v_nFCL xmldom.DOMNodeList;
v_nFCN xmldom.DOMNode;
v_nFCSourceL xmldom.DOMNodeList;
v_nFCSourceN xmldom.DOMNode;
v_nFCDestinationL xmldom.DOMNodeList;
v_nFCDestinationN xmldom.DOMNode;
m_nl xmldom.DOMNodeList;
m_n xmldom.DOMNode;
v_n xmldom.DOMNode;
v_n3 xmldom.DOMNodeList;
v_n4 xmldom.DOMNode;
v_b xmldom.DOMNode;
v_d xmldom.DOMNode;
v_a xmldom.DOMNodeList;
v_c xmldom.DOMNodeList;
m_prg xmldom.DOMNodeList;
m_pr xmldom.DOMNode;
condf_nl xmldom.DOMNodeList;
condf_n xmldom.DOMNode;
msgdtl_nl xmldom.DOMNodeList;
msgdtl_n xmldom.DOMNode;
rtndbt_nl xmldom.DOMNodeList;
rtndbt_n xmldom.DOMNode;
dnlt_nl xmldom.DOMNodeList;
dnlt_n xmldom.DOMNode;
cancl_nl xmldom.DOMNodeList;
cancl_n xmldom.DOMNode;
conid_nl xmldom.DOMNodeList;
conid_n xmldom.DOMNode;
canclid_nl xmldom.DOMNodeList;
canclid_n xmldom.DOMNode;
par_ref number(10) :=0;
msgnum number(20):=0;
var1 number(30):=0;
rtnnum number(20):=0;
dnnum number(20):=0;
tpmsg number(20):=0;
condfpmt number(20):=0;
canclnum number(20):=0;
--Added the next variable
sequence_no number(20):=0;
--These are the new variables
condfpmt1 number(20):=0;
rtnnum1 number(20):=0;
dnnum1 number(20):=0;
tpmsg1 number(20):=0;
canclnum1 number(20):=0;
--changing
part_refid_value number(20);
parid_typ_n xmldom.DOMNode;
parid_typ_nl xmldom.DOMNodeList;
parid_id_nl xmldom.DOMNodeList;
parid_id_n xmldom.DOMNode;
party_ref_node xmldom.DOMNode;
var_pr_reg_typ VARCHAR2(2);
msgrtdbt_nl xmldom.DOMNodeList;
msgrtdbt_n xmldom.DOMNode;
kndrtdbt_nl xmldom.DOMNodeList;
kndrtdbt_n xmldom.DOMNode;
rsnrtdbt_nl xmldom.DOMNodeList;
rsnrtdbt_n xmldom.DOMNode;
datrtdbt_nl xmldom.DOMNodeList;
datrtdbt_n xmldom.DOMNode;
grssrtdbt_nl xmldom.DOMNodeList;
grssrtdbt_n xmldom.DOMNode;
currtdbt_nl xmldom.DOMNodeList;
currtdbt_n xmldom.DOMNode;
rtnnum2 number(20):=0;
msgdnlt_nl xmldom.DOMNodeList;
msgdnlt_n xmldom.DOMNode;
lvdnlt_nl xmldom.DOMNodeList;
lvdnlt_n xmldom.DOMNode;
datdnlt_nl xmldom.DOMNodeList;
datdnlt_n xmldom.DOMNode;
grsdnlt_nl xmldom.DOMNodeList;
grsdnlt_n xmldom.DOMNode;
curdnlt_nl xmldom.DOMNodeList;
curdnlt_n xmldom.DOMNode;
limdnlt_nl xmldom.DOMNodeList;
limdnlt_n xmldom.DOMNode;
lvimp number(20);
nullchk varchar2(30) ;
chk_flseq number(10);
fl_seq number(30);
--these are the new variables
TYPE tab_type IS TABLE OF FileControl%ROWTYPE;
t_tab_FC tab_type := tab_type();
TYPE tab_type1 IS TABLE OF MessageTab%ROWTYPE;
t_tab1 tab_type1 := tab_type1();
TYPE tab_type2 IS TABLE OF ContractsWithDefaultOfPayment%ROWTYPE;
t_tab2 tab_type2 := tab_type2();
TYPE tab_type3 IS TABLE OF CancellationTab%ROWTYPE;
t_tab3 tab_type3 := tab_type3();
TYPE tab_type4 IS TABLE OF ReturnDebitNoteTab%ROWTYPE;
t_tab4 tab_type4 := tab_type4();
TYPE tab_type5 IS TABLE OF DunningLettersTab%ROWTYPE;
t_tab5 tab_type5 := tab_type5();
cursor MessageCursor is
select * from OM_BSN_STATEMSGS
where PROCESSED is null AND SENT in(Select min(SENT) from OM_BSN_STATEMSGS
where PROCESSED is null)
order by sent asc;
v_statemsgs OM_BSN_STATEMSGS%ROWTYPE;
BEGIN
DBMS_OUTPUT.put_line('creating parser');
-- v_parser := DBMS_XMLPARSER.NEWPARSER;
v_parser := DBMS_XMLPARSER.NEWPARSER();
DBMS_OUTPUT.put_line('done creating');
DBMS_XMLPARSER.setValidationMode(v_parser, true);
DBMS_XMLPARSER.showWarnings(v_parser, true);
open MessageCursor;
loop
fetch MessageCursor into v_statemsgs;
exit when MessageCursor%NOTFOUND;
DBMS_XMLPARSER.PARSECLOB(P => v_parser, DOC => v_statemsgs.MESSAGE);
-- xmlparser.parse(v_parser, File_Location);
v_doc := xmlparser.getDocument(v_parser);
dbms_xmlparser.freeParser(v_parser); DBMS_OUTPUT.put_line('Step 1');
v_nFCL := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/Statemessages/FileControl');
v_nFCN := xmldom.item(v_nFCL,0);
Source
v_nFCSourceL := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/Statemessages/FileControl/Source');
v_nFCSourceN := xmldom.item(v_nFCSourceL,0);
Destination
v_nFCDestinationL := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/Statemessages/FileControl/Destination');
v_nFCDestinationN := xmldom.item(v_nFCDestinationL,0);
-- Populate tab type for ORFC
t_tab_FC.extend;
t_tab_FC(t_tab_FC.last).creation_date := to_date(xslprocessor.valueOf(v_nFCN,'CreationDate'),'YYYY-MM-DD');
t_tab_FC(t_tab_FC.last).src_sys_id := xslprocessor.valueOf(v_nFCSourceN,'SystemID');
t_tab_FC(t_tab_FC.last).src_mandant_id := xslprocessor.valueOf(v_nFCSourceN,'MandantID');
t_tab_FC(t_tab_FC.last).dest_sys_id := xslprocessor.valueOf(v_nFCDestinationN,'SystemID');
t_tab_FC(t_tab_FC.last).dest_mandant_id := xslprocessor.valueOf(v_nFCDestinationN,'MandantID');
t_tab_FC(t_tab_FC.last).seq_no := xslprocessor.valueOf(v_nFCN,'SequenceNumber');
t_tab_FC(t_tab_FC.last).counter := xslprocessor.valueOf(v_nFCN,'Counter');
--Saving the value of this seq_no so that it can be inserted in the message tab.
sequence_no:= xslprocessor.valueOf(v_nFCN,'SequenceNumber');
--Insert into ORFC TAB
fl_seq := xslprocessor.valueOf(v_nFCN,'SequenceNumber');
select count(*) into chk_flseq from FileControl where SEQ_NO =fl_seq;
if (chk_flseq =0) then
FOR each_FC IN t_tab_FC.first .. t_tab_FC.last LOOP
INSERT INTO FileControl
creation_date,
src_sys_id,
src_mandant_id,
dest_sys_id,
dest_mandant_id,
seq_no,
counter)
VALUES
t_tab_FC(each_FC).creation_date,
t_tab_FC(each_FC).src_sys_id ,
t_tab_FC(each_FC).src_mandant_id,
t_tab_FC(each_FC).dest_sys_id,
t_tab_FC(each_FC).dest_mandant_id,
t_tab_FC(each_FC).seq_no,
t_tab_FC(each_FC).counter
END LOOP;
end if;
DBMS_OUTPUT.put_line('Step 2');
if (chk_flseq =0) then /* chk the xml's filecontrol seq exists in filecontrltab */
-- Use XPATH syntax to assign values to he elements of the collection.
v_nl := xslprocessor.selectNodes(xmldom.makeNode(v_doc),'/Statemessages/Message');
tpmsg := xmldom.getLength(v_nl);
DBMS_OUTPUT.put_line('Message node length'||tpmsg);
if (tpmsg>0) then
FOR cur_emp IN 0 .. xmldom.getLength(v_nl) - 1 LOOP
v_n := xmldom.item(v_nl, cur_emp);
select (BISON_OM_MessageID.NEXTVAL) into var1 from dual;
t_tab1.extend;
t_tab1(t_tab1.last).message_id := var1;
t_tab1(t_tab1.last).seq_no := sequence_no;
---party reg
m_prg := xslprocessor.selectNodes(v_n,'PartyRegistrationID');
FOR Ref_Id_Loop IN 0 .. xmldom.getLength(m_prg) - 1 LOOP
party_ref_node := xmldom.item(m_prg,0);
part_refid_value := xslprocessor.valueOf(party_ref_node,'.');
end loop;
m_pr := xmldom.item(m_prg, 0);
--changing
--chang id
parid_id_nl := xslprocessor.selectNodes(m_pr,'ID');
DBMS_OUTPUT.put_line('Going to read PartyRegistrationID');
FOR cur_parid_id IN 0 .. xmldom.getLength(parid_id_nl) - 1 LOOP
parid_id_n := xmldom.item(parid_id_nl,cur_parid_id);
DBMS_OUTPUT.put_line('Value of id:'|| xslprocessor.valueOf(parid_id_n,'.'));
t_tab1(t_tab1.last).party_ref_id := xslprocessor.valueOf(parid_id_n,'.');
exit;
end loop ;
---- change id
parid_typ_nl := xslprocessor.selectNodes(m_pr,'Type');
FOR cur_parid_typ IN 0 .. xmldom.getLength(parid_typ_nl) - 1 LOOP
parid_typ_n := xmldom.item(parid_typ_nl,cur_parid_typ);
var_pr_reg_typ := xslprocessor.valueOf(parid_typ_n,'.');
if var_pr_reg_typ='RG' then
t_tab1(t_tab1.last).PARTY_REG_TYPE_RG := var_pr_reg_typ;
elsif var_pr_reg_typ='AG' then
t_tab1(t_tab1.last).PARTY_REG_TYPE_AG := var_pr_reg_typ;
end if;
end loop;
--Chang
-- t_tab1(t_tab1.last).PARTY_REG_TYPE_AG := xslprocessor.valueOf(m_pr,'Type');
par_ref :=xslprocessor.valueOf(m_pr,'ID');
t_tab1(t_tab1.last).customer_grp_id := xslprocessor.valueOf(v_n,'CustomerGroupID');
t_tab1(t_tab1.last).name := xslprocessor.valueOf(v_n,'Name');
t_tab1(t_tab1.last).subname := xslprocessor.valueOf(v_n,'Subname');
t_tab1(t_tab1.last).datetime := xslprocessor.valueOf(v_n,'DateTime');
DBMS_OUTPUT.put_line('Step 3 ContractsWithDefaultOfPayment');
m_nl := xslprocessor.selectNodes(v_n,'DefaultOfPayment');
m_n := xmldom.item(m_nl, 0);
t_tab1(t_tab1.last).payment_msg_id := xslprocessor.valueOf(m_n,'MessageID');
t_tab1(t_tab1.last).gross_amt_before := xslprocessor.valueOf(m_n,'GrossAmountBefore');
t_tab1(t_tab1.last).gross_amt_current := xslprocessor.valueOf(m_n,'GrossAmountCurrent');
t_tab1(t_tab1.last).currency := xslprocessor.valueOf(m_n,'Currency');
t_tab1(t_tab1.last).settlemen_of_balance := xslprocessor.valueOf(m_n,'SettlementOfBalance');
t_tab1(t_tab1.last).including_subsidiary_claim := xslprocessor.valueOf(m_n,'IncludingSubsidiaryClaim');
condf_nl := xslprocessor.selectNodes(v_n,'ContractsWithDefaultOfPayment');
condf_n := xmldom.item(condf_nl,0);
condfpmt := xmldom.getLength(condf_nl);
if (condfpmt > 0) then
conid_nl := xslprocessor.selectNodes(condf_n,'ContractID');
FOR cur_conid IN 0 .. xmldom.getLength(conid_nl) - 1 LOOP
conid_n := xmldom.item(conid_nl,cur_conid);
t_tab2.extend;
t_tab2(t_tab2.last).message_id := var1;
t_tab2(t_tab2.last).contract_id := xslprocessor.valueOf(conid_n,'.');
end loop;
condfpmt1 := 1;
end if;
cancl_nl := xslprocessor.selectNodes(v_n,'Cancellation');
cancl_n := xmldom.item(cancl_nl,0);
DBMS_OUTPUT.put_line('No of cancellations'||xmldom.getLength(cancl_nl) );
canclnum := xmldom.getLength(cancl_nl) ;
if (canclnum > 0) then
canclid_nl := xslprocessor.selectNodes(cancl_n,'MessageID');
FOR cur_canclid IN 0 .. xmldom.getLength(canclid_nl) - 1 LOOP
canclid_n := xmldom.item(canclid_nl,cur_canclid);
t_tab3.extend;
t_tab3(t_tab3.last).message_id := var1;
t_tab3(t_tab3.last).cancellation_msg_id := xslprocessor.valueOf(canclid_n,'.');
end loop;
canclnum1 :=1;
end if; -- canclnum
msgdtl_nl := xslprocessor.selectNodes(v_n,'Messagedetails');
msgnum := xmldom.getLength(msgdtl_nl) ;
dbms_output.put_line('msgggg::::'||msgnum);
if (msgnum >0) then
msgdtl_n := xmldom.item(msgdtl_nl,0);
rtndbt_nl := xslprocessor.selectNodes(msgdtl_n,'ReturnDebitNote');
rtndbt_n := xmldom.item(rtndbt_nl,0);
rtnnum := xmldom.getLength(rtndbt_nl) ;
if (rtnnum >0) then
--return debit note
msgrtdbt_nl := xslprocessor.selectNodes(rtndbt_n,'MessageID');
kndrtdbt_nl := xslprocessor.selectNodes(rtndbt_n,'KindOf');
rsnrtdbt_nl := xslprocessor.selectNodes(rtndbt_n,'Reason');
datrtdbt_nl := xslprocessor.selectNodes(rtndbt_n,'Date');
grssrtdbt_nl := xslprocessor.selectNodes(rtndbt_n,'GrossAmount');
currtdbt_nl := xslprocessor.selectNodes(rtndbt_n,'Currency');
rtnnum2 :=0;
FOR cur_msgrtndbt IN 0 .. xmldom.getLength(msgrtdbt_nl) - 1 LOOP
msgrtdbt_n := xmldom.item(msgrtdbt_nl,cur_msgrtndbt);
kndrtdbt_n := xmldom.item(kndrtdbt_nl,cur_msgrtndbt);
rsnrtdbt_n := xmldom.item(rsnrtdbt_nl,cur_msgrtndbt);
datrtdbt_n := xmldom.item(datrtdbt_nl,cur_msgrtndbt);
grssrtdbt_n := xmldom.item(grssrtdbt_nl,cur_msgrtndbt);
currtdbt_n := xmldom.item(currtdbt_nl,cur_msgrtndbt);
t_tab4.extend;
t_tab4(t_tab4.last).message_id := var1;
t_tab4(t_tab4.last).ret_debitnote_msg_id := xslprocessor.valueOf(msgrtdbt_n,'.');
t_tab4(t_tab4.last).kind_of := xslprocessor.valueOf(kndrtdbt_n,'.');
t_tab4(t_tab4.last).Reason := xslprocessor.valueOf(rsnrtdbt_n,'.');
t_tab4(t_tab4.last).debit_note_date := to_date(xslprocessor.valueOf(datrtdbt_n,'.'),'YYYY-MM-DD');
t_tab4(t_tab4.last).gross_amt := xslprocessor.valueOf(grssrtdbt_n,'.');
t_tab4(t_tab4.last).currency := xslprocessor.valueOf(currtdbt_n,'.');
rtnnum1 :=rtnnum1 + 1;
rtnnum2 := rtnnum2 + 1;
dbms_output.put_line('message_id::::'||var1);
dbms_output.put_line('rtnnum2::::'||rtnnum2);
dbms_output.put_line('ret_debitnote_msg_id:::'||t_tab4(t_tab4.last).ret_debitnote_msg_id);
end loop;
----return debit note
t_tab4(t_tab4.last).message_id := var1 ;
t_tab4(t_tab4.last).ret_debitnote_msg_id := xslprocessor.valueOf(rtndbt_n,'MessageID');
t_tab4(t_tab4.last).kind_of := xslprocessor.valueOf(rtndbt_n,'KindOf');
t_tab4(t_tab4.last).reason := xslprocessor.valueOf(rtndbt_n,'Reason');
t_tab4(t_tab4.last).debit_note_date := to_date(xslprocessor.valueOf(rtndbt_n,'Date'),'YYYY-MM-DD');
t_tab4(t_tab4.last).gross_amt := xslprocessor.valueOf(rtndbt_n,'GrossAmount');
t_tab4(t_tab4.last).currency := xslprocessor.valueOf(rtndbt_n,'Currency');
rtnnum1 :=1;
end if;
dnlt_nl := xslprocessor.selectNodes(msgdtl_n,'DunningLetter');
dnlt_n := xmldom.item(dnlt_nl, 0);
dnnum := xmldom.getLength(dnlt_nl) ;
if (dnnum >0) then
-- t_tab5.extend;
--dunning letter
msgdnlt_nl := xslprocessor.selectNodes(dnlt_n,'MessageID');
lvdnlt_nl := xslprocessor.selectNodes(dnlt_n,'Level');
datdnlt_nl := xslprocessor.selectNodes(dnlt_n,'Date');
grsdnlt_nl := xslprocessor.selectNodes(dnlt_n,'GrossAmount');
curdnlt_nl := xslprocessor.selectNodes(dnlt_n,'Currency');
limdnlt_nl := xslprocessor.selectNodes(dnlt_n,'LevelImprovement');
FOR cur_msgdnlt IN 0 .. xmldom.getLength(msgdnlt_nl) - 1 LOOP
msgdnlt_n := xmldom.item(msgdnlt_nl,cur_msgdnlt);
lvdnlt_n := xmldom.item(lvdnlt_nl,cur_msgdnlt);
datdnlt_n := xmldom.item(datdnlt_nl,cur_msgdnlt);
grsdnlt_n := xmldom.item(grsdnlt_nl,cur_msgdnlt);
curdnlt_n := xmldom.item(curdnlt_nl,cur_msgdnlt);
limdnlt_n := xmldom.item(limdnlt_nl,cur_msgdnlt);
t_tab5.extend;
t_tab5(t_tab5.last).message_id := var1;
t_tab5(t_tab5.last).dunning_msg_id := xslprocessor.valueOf(msgdnlt_n,'.');
t_tab5(t_tab5.last).d_level := xslprocessor.valueOf(lvdnlt_n,'.');
t_tab5(t_tab5.last).dunning_date := to_date(xslprocessor.valueOf(datdnlt_n,'.'),'YYYY-MM-DD');
t_tab5(t_tab5.last).gross_amt := xslprocessor.valueOf(grsdnlt_n,'.');
t_tab5(t_tab5.last).currency := xslprocessor.valueOf(curdnlt_n,'.');
lvimp := xmldom.getLength(limdnlt_nl);
begin
t_tab5(t_tab5.last).level_improvement := xslprocessor.valueOf(limdnlt_n,'.');
EXCEPTION
WHEN OTHERS THEN
t_tab5(t_tab5.last).level_improvement := null;
end;
dnnum1 :=dnnum1 + 1;
-- dnnum2 := dnnum2 + 1;
dbms_output.put_line('message_id::::'||var1);
end loop;
----dunning letter
t_tab5(t_tab5.last).message_id := var1;
t_tab5(t_tab5.last).dunning_msg_id := xslprocessor.valueOf(dnlt_n,'MessageID');
t_tab5(t_tab5.last).d_level := xslprocessor.valueOf(dnlt_n,'Level');
t_tab5(t_tab5.last).dunning_date := to_date(xslprocessor.valueOf(dnlt_n,'Date'),'YYYY-MM-DD');
t_tab5(t_tab5.last).gross_amt := xslprocessor.valueOf(dnlt_n,'GrossAmount');
t_tab5(t_tab5.last).currency := xslprocessor.valueOf(dnlt_n,'Currency');
t_tab5(t_tab5.last).level_improvement := xslprocessor.valueOf(dnlt_n,'LevelImprovement');
dnnum1 :=1; */
end if;
end if;
END LOOP;
-- Insert data into the real EMP table from the table collection.
-- Form better performance multiple collections should be used to allow
-- bulk binding using the FORALL construct but this would make the code
-- too long-winded for this example.
DBMS_OUTPUT.put_line('Step 5');
FOR cur_emp IN t_tab1.first .. t_tab1.last LOOP
INSERT INTO MessageTab
message_id,
PARTY_REF_ID,
PARTY_REG_TYPE_AG,
party_reg_type_rg,
customer_grp_id,
name,
subname,
datetime,
payment_msg_id,
gross_amt_before,
gross_amt_current,
currency,
settlemen_of_balance,
including_subsidiary_claim,
seq_no)
VALUES
t_tab1(cur_emp).message_id,
t_tab1(cur_emp).PARTY_REF_ID,
t_tab1(cur_emp).PARTY_REG_TYPE_AG,
t_tab1(cur_emp).PARTY_REG_TYPE_RG,
t_tab1(cur_emp).customer_grp_id,
t_tab1(cur_emp).name,
t_tab1(cur_emp).subname,
t_tab1(cur_emp).datetime,
t_tab1(cur_emp).payment_msg_id,
t_tab1(cur_emp).gross_amt_before,
t_tab1(cur_emp).gross_amt_current,
t_tab1(cur_emp).currency,
t_tab1(cur_emp).settlemen_of_balance,
t_tab1(cur_emp).including_subsidiary_claim,
t_tab1(cur_emp).seq_no
END LOOP;
DBMS_OUTPUT.put_line('Step 6');
if (condfpmt1 > 0) then
FOR cur_cnf IN t_tab2.first .. t_tab2.last LOOP
INSERT INTO ContractsWithDefaultOfPayment
(message_id,contract_id)
values
(t_tab2(cur_cnf).message_id,t_tab2(cur_cnf).contract_id );
end loop;
end if; -- condfpmt
if (canclnum1 > 0) then
FOR cur_cancl IN t_tab3.first .. t_tab3.last LOOP
INSERT INTO CancellationTab
(message_id,cancellation_msg_id)
VALUES
(t_tab3(cur_cancl).message_id,t_tab3(cur_cancl).cancellation_msg_id);
END LOOP;
end if;
DBMS_OUTPUT.put_line('Step 7');
if (rtnnum1 >0) then
FOR cur_rtndb IN t_tab4.first .. t_tab4.last LOOP
INSERT INTO ReturnDebitNoteTab
(message_id,
ret_debitnote_msg_id,
kind_of,
reason,
debit_note_date,
gross_amt,
currency
VALUES
(t_tab4(cur_rtndb).message_id,
t_tab4(cur_rtndb).ret_debitnote_msg_id,
t_tab4(cur_rtndb).kind_of,
t_tab4(cur_rtndb).reason,
t_tab4(cur_rtndb).debit_note_date,
t_tab4(cur_rtndb).gross_amt,
t_tab4(cur_rtndb).currency);
END LOOP;
end if;
if (dnnum1 >0) then
FOR cur_dnl IN t_tab5.first .. t_tab5.last LOOP
INSERT INTO DunningLettersTab
(message_id,
dunning_msg_id,
d_level,
dunning_date,
gross_amt,
currency,
level_improvement)
VALUES
(t_tab5(cur_dnl).message_id,
t_tab5(cur_dnl).dunning_msg_id,
t_tab5(cur_dnl).d_level,
t_tab5(cur_dnl).dunning_date,
t_tab5(cur_dnl).gross_amt,
t_tab5(cur_dnl).currency,
t_tab5(cur_dnl).level_improvement
END LOOP;
DBMS_OUTPUT.put_line('Step 8');
end if; -- dnn
end if; -- top msg
end if; --- fl_seq chk
COMMIT;
-- Free any resources associated with the document now it
-- is no longer needed.
xmldom.freeDocument(v_doc);
/* refresh array */
t_tab_FC.delete;
t_tab1.delete;
t_tab2.delete;
t_tab3.delete;
t_tab4.delete;
t_tab5.delete;
/* refsh */
end loop;
close MessageCursor;
END ;
//Errors thrown by Oracle always show a line number (even if it points to the FOR loop that the error occurred within). When you run it, what is the error stack that is being returned. Copy and paste that, don't summarize it.
If you are still uncertain, add a final
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);to have it written out where your normal dbms_output goes. This is your friend in 10g for tracking down errors.
"But as soon as i add a prefix in the header everything works fine."
Is that header in the sample XML you provided? Regardless what are you adding? Your data is a clob so you can always tweak it before converting it to a DOMDocument just by doing simple string manipulation.
Since you are in 10g, you should be using dbms_xmldom instead of xmldom. I think xmldom is just a synonym for dbms_xmldom though. Review the dbms_xmldom documentation. You can go straight from a clob to a DOMDocument via DBMS_XMLDOM.NEWDOMDOCUMENT. You can also parse the document completely using dbms_xmldom calls instead of xslprocessor calls.
Other random things to evaluate:
Consider turning
FOR each_FC IN t_tab_FC.first .. t_tab_FC.last LOOP
INSERT INTO FileControl
into a
FORALL i IN t_tab_FC.first .. t_tab_FC.last LOOP
INSERT INTO FileControl
...Better performance because one two context switches (PL/SQL -> SQL -> PL/SQL) instead of 2*n switches.
I like this construct better
TYPE tab_type IS TABLE OF FileControl%ROWTYPE INDEX BY BINARY_INTEGER;
t_tab_FC tab_type := tab_type;because then you don't have to t_tab_FC.extend;you can just do something like index := 1;
LOOP
t_tab_FC(index).creation_date := <whatever>;
index := index + 1;
END LOOPYou also have the option of parsing your XML as a XMLType, including purely in SQL, but you can research that avenue at a later date.
Forgot to mention, wrap any code examples in [ pre ] [ pre ] (without the spaces) to retain your formatting. -
JaxB Javadoc on elements of classes generated
I am using JaxB 1.0 and having problems getting Javadoc into the generated classes. I can get the javadoc from the xsd file into the generate class at the class level but not have the get setter level
Below is a listing of what I have been able to get to compile but it does nothing to generate in the class on the following methods.
void setInEjbContext(boolean value);
com.acxiom.arch.configuration.schemaobjects.base.ContainerDatasources getContainerDataSources();
<xsd:element name="UseActivationKeySecurity" type="xsd:boolean" default="true">
<xsd:annotation>
<xsd:appinfo>
<jaxb:property>
<jaxb:javadoc>
When set to true KBA will use SECURITY_ROLE in the activation key params table associated with the service and check security.
</jaxb:javadoc>
</jaxb:property>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>That did not help. I can't get JaxB to put the java doc comments on elements in the generate classes. I can get package level and class level comments but not element level.
-
Remove namespace from element name
hello,
which is the most efficient way to remove the namespace from the name of all the elements of a dom document ?
eg:
<ns1:mytag>aaa</ns1:mytag> should become <mytag>aaa</mytag>
is it possible to have an example in java ?
thanks
robertoPersonally I would write an XSLT to do that. Just modify the identity transformation to write out elements with no namespace prefix.
-
JAXB marshalling complexType elements
Does anyone know why JAXB always marshalls complexType elements with a seperate start and end tag, even if the element has no content?
i.e.
Given the schema element declaration:
<xs:element name="foo" type="fooType"/>
<xs:complexType name="fooType">
<xs:attribute name="value" type="xs:string" use="required"/>
</xs:complexType>
Why do I get:
<foo value="bar"></foo>
Instead of:
<foo value="bar"/>
Is their a setting / property to control this behaviour?
If not then I certainly think there should be because this will bloat the 5Mb XML files I am currently dealing with by quite a lot.
Cheers,
SimonI have exactly the same trouble here. Did you find a solution? If so, please contact me. I am so afraid of increase the amount space used to store all XML files.
Thanks in advance
Julio Garc�a
[email protected] -
Jaxb -binding specific elements of schema to class
Is there a way to bind only specific elements from a schema to a class instead of binding everything in the schema. If yes, how do you specify this.
The <class> binding declaration customizes the binding of a schema element.
http://java.sun.com/xml/jaxb/users-guide/jaxb-custom.html#customdesc_class -
Sepecify namespace in Element clause
Suppose you have 2 schema files. One is Order.xsd, which defines global element Order and Item(Abstract), in namespace Order. Another one import this schema and subsititute the Item element with ComputerItem element, and uses ComputerOrder as target namespace. You registered both schemas (local => TRUE, gentypes => TRUE, genbean => FALSE, gentables => FALSE). Then you wanted to create a table based on ComputerItem.xsd,
create table cs of xmltype xmlschema "ComputerItem.xsd" element "Order"
Apparently, it does not work, xdb complains about 'Order' element not defined in ComputerItem.xsd. Is it because of namespaces or is it a limitation of xdb on import elements.
Thx!The schema files:
Order.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.bloomberg.com/Order" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:order="http://www.bloomberg.com/Order" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Order">
<xs:annotation>
<xs:documentation>This should be the root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element ref="order:Item"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Item" abstract="true">
<xs:annotation>
<xs:documentation>Items inside.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
ComputerItem.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.bloomberg.com/ComputerOrder" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:order="http://www.bloomberg.com/Order" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:import namespace="http://www.bloomberg.com/Order" schemaLocation="Order.xsd"/>
<xs:element name="ComputerItem" substitutionGroup="order:Item">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string"/>
<xs:element name="Price" type="xs:float"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema> -
I am currently using JAXB for data binding to our schemas. However, we maintain our schemas in each of our environments (Dev, Test, and Production). In each environment the schemas contain different namespace URIs that are relative to their environment.
Is there anyway to compile JAXB so that it doesn't care what NameSpace URI is? This is important when validation (via JAXP) occurs so it doesn't fail when unmarshaling an XML instance generated from a different environment.
If this is not possible my only option would be to compile 3 sets of objects for dev, test, and production which would not be a great approach : (
Thanks
BrianHaving different name spaces but wanting one set of objects seem contradictory. The motivation for wanting separate name spaces frequently justifies separate objects.
You could try specifying the same value to -p when you compile each of the schemas. This would place the bindings in the same package. However, you might run into name collisions, which you then would need to resolve (with an external binding file, e.g.).
Regards,
-- Ed -
Code to sort un-common elements in arrays
the code which i made so far
class ArraySetExample
public static void main (String [] args)
String rainbow [] = {"red","orange","yellow","green","blue","indigo","violet"};
String flag [] = {"red","white","blue"};
// To printout the set of common colours in flag and rainbow
System.out.println("the set of rainbow colours in the national flag");
for (int i=0; i<flag.length;i++)
for (int j=0; j<rainbow.length;j++)
if (flag.equals(rainbow[j])) System.out.println(flag[i]);
now i want to add String flagcolours[] // colours which are in flag but not in rainbow
String rainbowcolours[] // colours which are in rainbow but not flagthe logic which i thought isflagcolours.addAll(rainbow);
flagcolours.removeAll(flag);
rainbowcolours.addAll(flag);
rainbowcolours.removeAll(rainbow);but i want a code in arrays. can someone sort my missing code or anything if I have done wrongclass ArraySetExample
public static void main (String [] args)
String rainbow [] = {"red","orange","yellow","green","blue","indigo","violet"};
String flag [] = {"red","white","blue"};
String flagcolours[]; // colours which are in flag but not in rainbow
String rainbowcolours[]; // colours which are in rainbow but not flag
// To printout the set of colours in flag and rainbow
System.out.println("the set of rainbow colours in the national flag");
for (int i=0; i<flag.length;i++)
for (int j=0; j<rainbow.length;j++)
if (flag[i].equals(rainbow[j])) System.out.println(flag[i]);
//............MISSING CODE.............
Edited by: crystalarun on Oct 21, 2007 8:13 AMThen you will probably need to create a new array for each intersection and using nested for loops add items to your arrays depending on whether they are in one array and not in another by checking in an if-block. First work out what you would do on paper, then translate this to java. It's not hard once you see the solution on paper.
Good luck. -
Hi,
Consider this XML:
<container>
<items>
<item/>
<item/>
<item/>
<!-- ... -->
</items>
</container>
as of now, to get a list of items I need to make two calls: the first to get the object corresponding to the <items> element, and the second to get the actual items (e.g. container.getItems().getItems()).
Is it possible to create a complex type or a binding that would let me get item list in a single call (e.g. container.getItems())?If test.xsd looks like this:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="container">
<xs:complexType>
<xs:sequence>
<xs:element name="items">
<xs:complexType>
<xs:sequence minOccurs="1" maxOccurs="unbounded">
<xs:element name="item"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and you compile it like this:
xjc -p test test.xsd
this will create bindings that should let you unmarshal your instance into a Container class. That class will contain a getItem() method that returns a java.util.List of items.
-- Ed
Maybe you are looking for
-
I cannot open PDF files with my Mountain Lion system. What APP's do I need?
What Apps do I need to open PDF files with Mt. Lion installed?
-
Error during System Copy in SCM system
*Hi We are performing System Copy of SCM system. Java was not running in the system from the starting. we are facing following error while performing system copy* Please Help.. Oct 23, 2009 12:05:38... Info : Successfully parsed! Oct 23, 2009 12:0
-
Question on dispute management status profile
Dear Friends, I have a quetion on SAP FSCM dispute management status profile. While setting up the status profile we would specify the status values. A number is assigned to each status and it will have corresponding system status. In the standard de
-
Email saying activation complete?
Got the email saying the new # and activation is complete it also says on the bottom of email if you have not do so already please connect the iphone to you computer or click here if you phone is aleady connected so i click on link and now brings me
-
Db13 after system copy and oracle upgrade.
Dear support, I have 40B system with Oracle 8.1.7.4 with SID as PRD. Now i have copied the same to TST system and i forgot to perform ops$ mechanism setup in TST system as part of post database refresh. Now i have upgraded database to oracle 9.2.0.5