Namespace Prefix with DOM
Hey everyone,
I have a document and I would like to add a prefix to an existing tag so basically I want
<Record>
to be
<rec:Record>
the code I am trying is
private static void addRecPrefix(Document inDoc) throws XPathExpressionException
if (inDoc == null)
return;
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr = xpath.compile("//Record");
Object evalResult = expr.evaluate(inDoc, XPathConstants.NODESET);
if (evalResult == null)return;
NodeList record Tags = (NodeList)evalResult;
for(int i=0; i<recordTags.getLength() ;i++)
Node currentNode = recordTags.item(i);
currentNode.setPrefix("rec");
System.out.println(currentNode.getPrefix());
}rec is a namespace created in the parent node and it is part of the document, however, when I run the code I get a NAMESPACE_ERR.
How am I supposed to do this?
UPDATE!!!!!!!!
got it to work using this inside the loop
Node currentNode = cdfTags.item(i);
inDoc.renameNode(currentNode,"","rec:Record");
is this the best way?
Edited by: partyk1d24 on Jul 9, 2008 8:22 AM
Hi Rajiv,
Pl. go through this blog:
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
Also if you want to use this at sender side, SOAP adapter will not support. Please check stefans reply in this thread:
XMLAnonymizerBean doesnt work
Regards,
---Satish
Similar Messages
-
Remove namespace prefix with the XMLAnonymizerBean is possible at SOAP Adap
Hello,
I am wondering is it possible Remove namespace prefix with the XMLAnonymizerBean at SOAP Receiver Adaptor?
ThanksHi Rajiv,
Pl. go through this blog:
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
Also if you want to use this at sender side, SOAP adapter will not support. Please check stefans reply in this thread:
XMLAnonymizerBean doesnt work
Regards,
---Satish -
Setting namespace prefix with JAXB
I'm trying to build and use a JAXB application.
1. Generate the Java source files by submitting the XML Schema with Namespace to the binding compiler.
2. Compile the Java source code.
3. Marshal the data to new XML documents(valid XML document).
But namespace prefix of XML Schema doesn't equal namespace prefix of new XML document.
The prefix of new XML Schema is "heo". But, the prefix of new XML document set as "ns1" at discretion.
Is there any way to solve namespace prefix setting?
Thank you for your help.Why is java the only one doing this?
I know prefixes are arbitrary, but when groups/individuals design XML docs, the instinct is to specify unique prefixes and to expect them coming in and out of other systems.
When joe-developer emails an API to a buddy, she's got to include a lot more info every time, not just "cool:news" vs. "bad:news" but "cool:news" and "xmlns:cool=uri-foobar-smyte" and ...
Sooo much simpler to handle the xml when its not only declared correctly, but you can expect specific prefixes. Less lines in writing tests, less lines in parsing out namespace declarations in order to expand them to uris and then map those to the random prefixes... blah.
If you are concerned about dropping uri's then THAT should be the exception to the rule, then you write tests to lookup the namespace-uri.
I suppose sun's xml stack is kind of a lesson to teach us developers to handle xml the orthodox way, using random prefixes, thanks for that.
Classic: look at the amount of code it takes to parse xml in java. Then add on complexity (weirdness) in terms of random prefixes .... then compare that to .net/python/ruby/php/perl/c/c++ ... sun is all alone on this one and about 10x more verbose.
At least honor the xml prefixes declared and developers round the world will appreciate the boost in productivity.
Word!
-jhn -
Hi,
I have the following document
<ns4:product xmlns:ns1="www.abc.com" xmlns:ns2="www.def.com" xmlns:ns3="www.ghi.com" xmlns:ns4="www.jkl.com">
<ns4:productline>Widget</ns4:productline>
</ns4:product>
I'm trying to find a SQL function which will enable me to extract the namespace prefix with the value "www.jkl.com". This is so that I can then use the prefix as part of the xpath expression to search for an element value in the document eg. extractvalue('/ns4:product/ns4:productline')
ThanksHi,
This one's tricky, so tricky that I think it's not possible using Oracle built-in XML DML functions.
Even XQuery Update cannot do it (for now) because, likewise, the prefix is always redeclared at child level.
The only thing I can think of is XSLT (or maybe DOM manipulation) :
SQL> select xmlserialize(document
2 xmltransform(
3 xmltype('<A xmlns="namespace" xmlns:def="myns_namespace"/>')
4 , xmltype(
5 '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 xmlns:def="myns_namespace"
7 xmlns:ns0="namespace">
8 <xsl:template match="ns0:A">
9 <xsl:copy>
10 <xsl:element name="def:B"/>
11 </xsl:copy>
12 </xsl:template>
13 </xsl:stylesheet>')
14 )
15 indent
16 )
17 from dual;
XMLSERIALIZE(DOCUMENTXMLTRANSF
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B/>
</A> -
SQL function to extract XML namespace prefix
Hi,
I have the following document
<ns4:product xmlns:ns1="www.abc.com" xmlns:ns2="www.def.com" xmlns:ns3="www.ghi.com" xmlns:ns4="www.jkl.com">
<ns4:productline>Widget</ns4:productline>
</ns4:product>
I'm trying to find a SQL function which will enable me to extract the namespace prefix with the value "www.jkl.com". This is so that I can then use the prefix as part of the xpath expression to search for an element value in the document eg. extractvalue('/ns4:product/ns4:productline')
ThanksTry DBMS_XMLDOM.GetNameSpace
-
How to add an element with a namespace prefix (Part 2)
Hi all,
I previously asked a question about adding an attribute with a namespace prefix to an element that already exists and that declares the namespace prefix here:
https://forums.oracle.com/thread/2610142
I received an answer that works, but now I am stumped again when I have to add an element where the element name has the namespace prefix.
For example, let's say I already have this element:
<A xmlns="namespace" xmlns:def="myns_namespace"/>
And I want to add this element:
<def:B/>
To produce this:
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B/>
</A>
and NOT this:
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B xmlns:def="myns_namespace"/>
</A>
This does not work:
SELECT
xmlserialize(document
appendChildXML(
xmltype('<A xmlns="namespace" xmlns:def="myns_namespace"/>')
, '/A'
, xmlelement("def:D")
, 'xmlns="namespace" xmlns:def="myns_namespace"'
indent)
FROM dual;
Because of this error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00234: namespace prefix "def" is not declared
Error at line 1
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.
Is there any way to do this without the child element having the duplicate namespace declaration?
My oracle version is:
Oracle Database 11g Release 11.1.0.7.0 - 64bit ProductionHi,
This one's tricky, so tricky that I think it's not possible using Oracle built-in XML DML functions.
Even XQuery Update cannot do it (for now) because, likewise, the prefix is always redeclared at child level.
The only thing I can think of is XSLT (or maybe DOM manipulation) :
SQL> select xmlserialize(document
2 xmltransform(
3 xmltype('<A xmlns="namespace" xmlns:def="myns_namespace"/>')
4 , xmltype(
5 '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6 xmlns:def="myns_namespace"
7 xmlns:ns0="namespace">
8 <xsl:template match="ns0:A">
9 <xsl:copy>
10 <xsl:element name="def:B"/>
11 </xsl:copy>
12 </xsl:template>
13 </xsl:stylesheet>')
14 )
15 indent
16 )
17 from dual;
XMLSERIALIZE(DOCUMENTXMLTRANSF
<A xmlns="namespace" xmlns:def="myns_namespace">
<def:B/>
</A> -
Printing with Apex generates error (namespace prefix ref....)
Hello forum helpers,
i have installed bi publisher standalone and bi publisher desktop with MS Word 2003.
I have generated a rtf document as a template.
I loaded this rtf template into the apex database and started the TEST REPORT BUTTON in apex report queries.
But i have seen no report.
So, I have placed a xdodebug.cfg file into the folder java/jre/lib and so i have several logfiles created after processing printing.
This logfiles shows this lines, which i do not understand:
[030211_051252364][oracle.apps.xdo.template.FOProcessor][STATEMENT] Log file 'xdo_030211_051252364_fo_data_14.xsl' is created.
[030211_051252364][oracle.apps.xdo.template.FOProcessor][STATEMENT] FOProcessor.setData(InputStream) is called.
[030211_051252364][oracle.apps.xdo.template.FOProcessor][STATEMENT] Log file 'xdo_030211_051252364_fo_data_15.xml' is created.
[030211_051252379][oracle.apps.xdo.template.FOProcessor][STATEMENT] Log file 'xdo_030211_051252364_fo_out6.out' is created.
[030211_051252379][oracle.apps.xdo.template.FOProcessor][STATEMENT] FOProcessor.setOutput(OutputStream)is called.
[030211_051252379][oracle.apps.xdo.template.FOProcessor][STATEMENT] FOProcessor.setOutputFormat(byte)is called with ID=3.
[030211_051252379][oracle.apps.xdo.template.FOProcessor][STATEMENT] Start Memory: max=247MB, total=62MB, free=23MB
[030211_051252379][oracle.apps.xdo.template.FOProcessor][STATEMENT] FOProcessor.generate() called.
[030211_051252379][oracle.apps.xdo.template.FOProcessor][STATEMENT] createFO(Object, Object) is called.
[030211_051252395][oracle.apps.xdo.common.xml.XSLT10gR1][STATEMENT] Oracle XML Developers Kit 10.1.0.5.0 - Production
[030211_051252395][oracle.apps.xdo.common.xml.XSLT10gR1][STATEMENT] Scalable Feature Disabled
[030211_051252410][oracle.apps.xdo.common.xml.XSLTWrapper][ERROR] XSL error:
XML-22008: (Error) Namespace prefix 'ref' used but not declared.
[030211_051252410][oracle.apps.xdo.template.FOProcessor][STATEMENT] clearInputs(Object) is called.
[030211_051252426][oracle.apps.xdo.template.FOProcessor][STATEMENT] clearInputs(Object) done. All inputs are cleared.
[030211_051252426][oracle.apps.xdo.template.FOProcessor][ERROR] End Memory: max=247MB, total=62MB, free=20MB
[030211_051252426][][EXCEPTION] java.lang.reflect.InvocationTargetException
You see, that an xml-22008 Error appears.
In google i only found, that the declaration of this reference must be before using it. Seems to be logical.
But the template is generated by BI Publisher himself, so now i do not understand.
I have no choice to declare references, the xml file is made by bi publisher.
Has anyone a solution for this ?
Thank you for help.
FrankIssue was solved, found it in the bi publisher options in word 2003
-
Delete namespace and prefix with Seeburger X.400 receiver
Dear experts,
I have a problem deleting a namespace and prefixes "ns0" from an XML output. When testing I was using an FTP receiver adapter with the AnonymizerBean which worked perfectly. I referred to: /people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
Now I have a Seeburger X.400 receiver adapter and the AnonymizerBean does not work anymore.
The output message looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<ns0:ORDERRESPONSE xmlns:ns0="http://www.opentrans.org/XMLSchema/1.0" version="1.0">
<ns0:ORDERRESPONSE_HEADER>
<ns0:ORDERRESPONSE_INFO>
<ns0:ORDER_ID>xxxxx</ns0:ORDER_ID>
So I need to get rid of the namespace and the prefixes "ns0". Does anyone know how to configure the module of the X.400 receiver adapter to do this?
Thank you very much for your help!
Best regards,
PeterHey Guys,
I am having issues with using anonymizer bean. Below is the data with namespaces I would like to strip:
<?xml version="1.0" encoding="UTF-8" ?>
- <ns1:ExecuteXMLRequest xmlns:ns1="http://decisionintellect.com/inteport/">
- <ns1:_sRequestXML>
- <ns1:inteflow>
- <ns1:request cd_type="submit">
- <ns1:user>
<ns1:id_oper>INTERFACE</ns1:id_oper>
<ns1:tx_password>password</ns1:tx_password>
</ns1:user>
<ns1:cd_service>SUBMIT</ns1:cd_service>
<ns1:cd_product>IFE</ns1:cd_product>
<ns1:id_channel>INTEGATE</ns1:id_channel>
<ns1:id_company>OFFICEWORKS</ns1:id_company>
<ns1:id_merchant>OFFICEWORKS</ns1:id_merchant>
<ns1:cd_country>61</ns1:cd_country>
<ns1:cd_security>IFE</ns1:cd_security>
</ns1:request>
- <ns1:application_details>
<ns1:id_product_credit>COMMERCIAL DECISIONING</ns1:id_product_credit>
<ns1:id_reference_internal>[APP-ID]</ns1:id_reference_internal>
<ns1:id_reference_external>[customer ref here]</ns1:id_reference_external>
<ns1:id_merchant_submit>OFFICEWORKS</ns1:id_merchant_submit>
</ns1:application_details>
- <ns1:service>
- <ns1:application>
- <ns1:finance>
<ns1:cd_type_finance>TERMS 30</ns1:cd_type_finance>
<ns1:am_finance>4000</ns1:am_finance>
</ns1:finance>
- <ns1:applicant cd_type="Principal" fg_new="0">
- <ns1:company>
<ns1:cd_type_entity>SLTR</ns1:cd_type_entity>
<ns1:tx_company_abn>41552470947</ns1:tx_company_abn>
<ns1:nm_company_legal>WESTON, DEAN</ns1:nm_company_legal>
<ns1:cd_type_industry>OTHER</ns1:cd_type_industry>
<ns1:no_directors>1</ns1:no_directors>
<ns1:no_employees>1</ns1:no_employees>
</ns1:company>
</ns1:applicant>
- <ns1:applicant cd_type="CoBorrower1" fg_new="0">
- <ns1:individual>
<ns1:cd_title>Mr</ns1:cd_title>
<ns1:nm_firstname>Dean</ns1:nm_firstname>
<ns1:nm_surname>Weston</ns1:nm_surname>
<ns1:dt_dob>1968-12-29</ns1:dt_dob>
<ns1:cd_gender>M</ns1:cd_gender>
<ns1:fg_act_privacy>1</ns1:fg_act_privacy>
<ns1:cd_residence>61</ns1:cd_residence>
</ns1:individual>
- <ns1:address>
- <ns1:current_address>
<ns1:tx_no_unit>1</ns1:tx_no_unit>
<ns1:tx_no_street>1</ns1:tx_no_street>
<ns1:nm_street>Test</ns1:nm_street>
<ns1:cd_type_street>Rd</ns1:cd_type_street>
<ns1:nm_suburb>Testerville</ns1:nm_suburb>
<ns1:cd_state>VIC</ns1:cd_state>
<ns1:cd_postcode>3000</ns1:cd_postcode>
<ns1:ct_address_at_time>21</ns1:ct_address_at_time>
<ns1:cd_country>61</ns1:cd_country>
</ns1:current_address>
</ns1:address>
- <ns1:address>
- <ns1:previous_address>
<ns1:tx_no_street>2</ns1:tx_no_street>
<ns1:nm_street>Wayback</ns1:nm_street>
<ns1:cd_type_street>Crs</ns1:cd_type_street>
<ns1:nm_suburb>Sydney</ns1:nm_suburb>
<ns1:cd_state>NSW</ns1:cd_state>
<ns1:cd_postcode>2000</ns1:cd_postcode>
<ns1:ct_address_at_time>117</ns1:ct_address_at_time>
<ns1:cd_country>61</ns1:cd_country>
</ns1:previous_address>
</ns1:address>
- <ns1:identification>
- <ns1:drivers_license>
<ns1:id_number>123456789</ns1:id_number>
<ns1:fg_verified>1</ns1:fg_verified>
</ns1:drivers_license>
</ns1:identification>
- <ns1:contact>
- <ns1:home_phone>
<ns1:tx_area>03</ns1:tx_area>
<ns1:tx_number>99998888</ns1:tx_number>
</ns1:home_phone>
</ns1:contact>
- <ns1:contact>
- <ns1:work_phone>
<ns1:tx_area>03</ns1:tx_area>
<ns1:tx_number>88887777</ns1:tx_number>
</ns1:work_phone>
</ns1:contact>
- <ns1:contact>
- <ns1:other_phone>
<ns1:tx_number>0400123123</ns1:tx_number>
<ns1:cd_type>Mobile</ns1:cd_type>
</ns1:other_phone>
</ns1:contact>
- <ns1:contact>
- <ns1:other_phone>
<ns1:tx_area>03</ns1:tx_area>
<ns1:tx_number>77776666</ns1:tx_number>
<ns1:cd_type>Other</ns1:cd_type>
</ns1:other_phone>
</ns1:contact>
</ns1:applicant>
</ns1:application>
</ns1:service>
</ns1:inteflow>
</ns1:_sRequestXML>
</ns1:ExecuteXMLRequest>
Anonymizer bean is stripping the namespace prefix ns1 but it is also stripping the address http://decisionintellect.com/inteport/.
Below is my anonymizer bean config in PI:
Processing seq:
1 AF_Modules/XMLAnonymizerBean local enterprise bean 0
Module config:
0 anonymizer.acceptNamespaces http://decisionintellect.com/inteport ''
0 anonymizer.quote '
Can someone please suggest how to keep the http://decisionintellect.com/inteport and remove rest of namespace prefixes -
Using selectSingleNode with namespace prefixes like "xmlsns:xsi"???
I'm having a little trouble manipulating a document with the xmlparserv2 library. The XMLNode.selectSingleNode method does not seem to work when the attribute in question is part of a namespace. For example, I have a document that has a schema declaration like so:
****CUT****
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="..\XMLStressTestCase.xsl"?>
<XMLTestCase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../XmlStressTestCase.xsd" Name="Engenious (Switch) Eligible Test" MaxTime="30000">
****CUT****
If I create an XMLDocument (myDoc) from the file in question and try to execute the following line of code
Node n = myDoc.selectSingleNode("@xmlns:xsi");
I get the following error
" Namespace prefix 'xmlns' used but not declared."
In google I found a thread (http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=ugJD7hJ3BHA.2236%40tkmsftngp02&rnum=2&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3Dxmlns%2B%252B%2BselectSingleNode%26sa%3DN%26tab%3Dwg)that points to setProperty/selectionNamespaces
as qa possible way to resolve the problem in the MSXML implementation. It looks like the oracle XDK has the same method, but I can't seem to find any documentation on the values that are supported for that method (http://otn.oracle.com/docs/tech/xml/xdk_java/doc_library/Production9i/doc/java/javadoc/oracle/xml/parser/v2/XMLNode.html#setProperty(java.lang.String, java.lang.Object))
Any help? Should I be declaring the namespace in my XML someplace?In fact it used to be possible to set a NamespacePrefixMapper that controls the namespace prefixes in the JAXB 2.0 from Glasfish like this:
marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper", new MyNamespacePrefixMapper());
When using the Java 6 implementation of JAXB this coded will throw an exception. Has anyone got a clue how to control the namespace prefix in Java 6?
Thanks,
Ager -
Unknown namespace prefix Error - when using custom Aliases with RDF aliases
I am getting unknown namespace prefix error when I use custome SEM_ALIAS with rdf SEM_ALIAS. It seems once you specify custom SEM_ALIAS, the default rdf alias is not recognized. Following are the details of queries
I have a sem_Model "test" which has "event" as a class and "Merger" as a sub-class of event, with "acquiringorg" as a property having the domain "org". "Org" is also defined as a class with the literal attribute "hasname". I have added one instance of "merger" class with appropriate values for "acquiringorg" property. There is one instance or "Org" as well for reference in the instance above.
the following query(return all objects having property "acquiringorg" and its .e. "hasName" attribute for the object) runs fine and returns appropriate resultset
select x event,z acquiringorg ,l acquireeorg from table(SEM_MATCH(
'(?x Evnt:AcquiringOrg ?y)(?k orgn:hasName ?l)',
SEM_MODELS('test'),
null,
SEM_ALIASES(SEM_ALIAS('Evnt','http://www.abc.com/Event/Merger/'),
SEM_ALIAS('orgn','http://www.abc.com/Org/')),
null));
However when I want to add another criteria i.e. show me events of type merger(?x rdf:type :Merger) , the query fails with the "unknown namespace prefix error" as above
select x event,z acquiringorg ,l acquireeorg from table(SEM_MATCH(
'(?x rdf:type :Merger)(?x Evnt:AcquiringOrg ?y)(?k orgn:hasName ?l)',
SEM_MODELS('test'),
null,
SEM_ALIASES(SEM_ALIAS('Evnt','http://www.abc.com/Event/Merger/'),
SEM_ALIAS('orgn','http://www.abc.com/Org/')),
null));
specifying "rdf" ALIAS explicitly also does not work
select x event,z acquiringorg ,l acquireeorg from table(SEM_MATCH(
'(?x rdf:type :Merger)(?x Evnt:AcquiringOrg ?y)(?k orgn:hasName ?l)',
SEM_MODELS('test'),
null,
SEM_ALIASES(_SEM_ALIAS('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'),_
SEM_ALIAS('Evnt','http://www.abc.com/Event/Merger/'),
SEM_ALIAS('orgn','http://www.abc.com/Org/')),
null));
I am unable to figure out why default namespace i.e. rdf is returning this error
Stuck at this point badly!!Any pointers would be useful!!Full error details are as below
ORA-29532: Java call terminated by uncaught Java exception: oracle.spatial.rdf.server.ParseException: Unknown namespace prefix ''
ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 153
ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 842
ORA-06512: at "MDSYS.RDF_MATCH_IMPL_T", line 235
ORA-06512: at line 1
29532. 00000 - "Java call terminated by uncaught Java exception: %s"
*Cause: A Java exception or error was signaled and could not be
resolved by the Java code.
*Action: Modify Java code, if this behavior is not intended. -
XMLStreamReaderBase tries to create a QName with a null namespace prefix
Given the following xml:
<foo>
<bar type="value"/>
</foo>
Calling getAttributeName(index) while on the 'bar' element will cause an IllegalArgumentException as XMLStreamReaderBase tries to create a javax.xml.namespace.QName with a null prefix instead of using XMLConstants.DEFAULT_NS_PREFIX
java.lang.IllegalArgumentException: prefix cannot be "null" when creating a QName
at javax.xml.namespace.QName.<init>(QName.java:170)
at weblogic.xml.stax.XMLStreamReaderBase.getAttributeName(XMLStreamReaderBase.java:339)Hi, were you able to solve this issue? I am also facing the same!
Deepak -
Extracting XML values with namespace prefixes
Hint: I put this topic in "SQL and PL/SQL" but that was a bad idea, I think.
Hi!
I have a XML file:<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/styl.xsl"?>
<wnio:Deklaracja
xmlns:adr="http://crd.gov.pl/xml/schematy/adres/2008/05/09/"
xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:inst="http://crd.gov.pl/xml/schematy/instytucja/2008/05/09/"
xmlns:meta="http://crd.gov.pl/xml/schematy/meta/2008/05/09/"
xmlns:oso="http://crd.gov.pl/xml/schematy/osoba/2008/05/09/"
xmlns:str="http://crd.gov.pl/xml/schematy/struktura/2009/11/16/"
xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xsi:schemaLocation="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/ http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/schemat.xsd">
<wnio:OpisDokumentu><str:CID>[email protected]</str:CID><meta:Identyfikator typIdentyfikatora="idFormularza"><meta:Wartosc>InstytucjaPubliczna/Deklaracja podatku od środków transportowych DT-1</meta:Wartosc></meta:Identyfikator></wnio:OpisDokumentu>
<wnio:Naglowek>
<wnio:KodFormularza kodSystemowy="DT-1(3)"/>
<wnio:WariantFormularza>3</wnio:WariantFormularza>
<wnio:Rok>2008</wnio:Rok>
<wnio:ObowiazekSkladaniaDeklaracji>1</wnio:ObowiazekSkladaniaDeklaracji>
<wnio:MiejsceSkladania/>
</wnio:Naglowek>
<wnio:Podatnik>
<wnio:OsobaPrawna>
<wnio:NIP>345678901</wnio:NIP>
<wnio:PelnaNazwa>Testowa Instytucja Publiczna</wnio:PelnaNazwa>
<wnio:NazwaSkrocona/>
<wnio:REGON>234512345</wnio:REGON>
</wnio:OsobaPrawna>
<wnio:AdresSiedzibyZamieszkania>
<wnio:KodKraju>PL</wnio:KodKraju>
<wnio:Wojewodztwo>ŚLĄSKIE</wnio:Wojewodztwo>
<wnio:Powiat>Katowice</wnio:Powiat>
<wnio:Gmina>Katowice (gmina miejska)</wnio:Gmina>
<wnio:Ulica>ul. Mikołowska</wnio:Ulica>
<wnio:NrDomu>100</wnio:NrDomu>
<wnio:NrLokalu>924</wnio:NrLokalu>
<wnio:Miejscowosc>Katowice (miasto)</wnio:Miejscowosc>
<wnio:KodPocztowy>40-065</wnio:KodPocztowy>
<wnio:Poczta>Katowice</wnio:Poczta>
</wnio:AdresSiedzibyZamieszkania>
</wnio:Podatnik>
<wnio:PozycjeSzczegolowe>
<wnio:D.1>
<wnio:P_22/>
<wnio:P_23/>
</wnio:D.1>
<wnio:D.2>
<wnio:P_28/>
<wnio:P_29/>
</wnio:D.2>
<wnio:P_82/>
<wnio:P_83/>
</wnio:PozycjeSzczegolowe>
<wnio:Zalacznik_DT-1A>
<wnio:P_1/>
<wnio:P_2/>
<wnio:P_22>1</wnio:P_22>
</wnio:Zalacznik_DT-1A>
<wnio:Zalacznik_DT-1A>
<wnio:P_1/>
<wnio:P_2/>
<wnio:P_22>3</wnio:P_22>
</wnio:Zalacznik_DT-1A>
</wnio:Deklaracja>and an overloaded function:
function dodaj_DT1_z_xml(p_dt1 in out nocopy XMLType) return number as
r_dt1 POD_SRTR_DT1%rowtype;
r_dt1a POD_SRTR_DT1A%rowtype;
r_sdek POD_SRTR_DEKLARACJE%rowtype;
l_wariantDT1 number(2);
l_xosf XMLType;
l_xosp XMLType;
l_xadr XMLType;
l_xszcz XMLType;
l_zal XMLType;
l_z XMLType;
l_zno pls_integer;
l_xml XMLType;
l_ns varchar2(10);
-- xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"
begin
if --p_dt1.existsNode('/wnio:Deklaracja')=0 and
p_dt1.existsNode('/Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')=0
then return -2; end if;
if p_dt1.existsNode('/wnio:Deklaracja')=1 then
l_ns := 'wnio:';
end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja')=0 then return -2; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Naglowek')=0 then return -3; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'Podatnik')=0 then return -4; end if;
if p_dt1.existsNode('/'||l_ns||'Deklaracja/'||l_ns||'PozycjeSzczegolowe')=0 then return -5; end if;
return 1;
end;
function dodaj_DT1_z_xml(p_dt1 in out nocopy CLOB) return number is
l_xml XMLType;
begin
l_xml := XMLType(p_dt1);
return dodaj_DT1_z_xml(l_xml);
end dodaj_DT1_z_xml;I run the code:declare
v_clob CLOB;
v_out number;
begin
SELECT dok_content INTO v_clob FROM EPUAP.epuap_dokumenty WHERE dok_id=13;
v_out := POD_PCK_SRTR_DT1.DODAJ_DT1_Z_XML(v_clob);
DBMS_OUTPUT.put_line(v_out);
end;the output is -2. What must I change to find the node "wnio:Deklaracja"? I'm newbie in XML and namespaces :(
Help me, please...
Oracle version is 10.2.0.3Hi,
If you declare a namespace prefix then corresponding elements must be qualified.
So, either do :
p_dt1.existsNode('/wnio:Deklaracja','xmlns:wnio="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')or use a default namespace declaration :
p_dt1.existsNode('/Deklaracja','xmlns="http://test.epuap.gov.pl/FeResourceServlet/wzor_lokalny/InstytucjaPubliczna/Deklaracja_DT/"')BTW, could you explain what are you trying to accomplish? -
Dear all,
I'm using code generated by NW Developer Studio 2004s for use inside Portal components acting as a web service consumer. The problem is that the code generated includes a namespace prefix for each element in the body of the message, but ECC (ERP 6.0) doesn't like the namespace prefixes (the namespace was not recognised by the ECC mapping tool.)and throws back a DeliveryException.
The SOAP message created by the generated NWDS code is:
<?xml version="1.0" encoding="UTF-8" ?>
- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wn3="http://www.w3.org/1999/XMLSchema" xmlns:wn2="http://www.w3.org/2000/10/XMLSchema" xmlns:wn1="http://www.w3.org/2001/XMLSchema" xmlns:wn0="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn4="urn:sap-com:document:sap:rfc:functions" xmlns:tns="urn:sap-com:document:sap:rfc:functions">
- <SOAP-ENV:Body>
- <wn4:Z_APPOINTMENT_GET_JCO_ORG>
<wn4:DATE_FROM>2007.01.01</wn4:DATE_FROM>
<wn4:DATE_TO>2008-02-02</wn4:DATE_TO>
<wn4:USERID>EGREO</wn4:USERID>
</wn4:Z_APPOINTMENT_GET_JCO_ORG>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
I've had a very good look around the generated code - the serializers for creating the soap request - but could not find what exactly might be changed to leave off the prefixes.
I am using portal server 2004s
Many thanks for any advice/help
RezaI find out how should I do that.
/Reza -
Xpath with unknown namespace prefix
Given XML that looks like this
<nnn:XXX>
<mmm:YYY>value</mmm:YYY>
</nnn:XXX>
And in the above the 'mmm' can vary but the 'YYY' doesn't.
Can one construct an XPath expression that explicity returns the node-set for the inner element block using 'YYY'?
I am not looking for a first node or indexed solution but rather one that explicitly uses 'YYY' and not 'mmm' in some way.
I tried several variations (guesses) using the function Contains but that did nothing but produce syntax errors.The namespace prefix is meaningless, it's only the namespace URI that is significant, so there's no XPath way of searching given a namespace prefix. But fortunately you have the opposite problem, you don't care about the namespace at all. The XPath function local-name() returns the local part of the name of a node, in your example the "YYY" part of the element name.
-
To convert XML to ABAP internal table can we do it with DOM or we need XSLT
I have a requirement where I need to collect the data from XML file into an internal table.
I need to collect this data into an internal table as I should make use of this data and do Goods Receipt in SAP.
My XML file is very very complex and the child nodes in my XML file may occur ones or 10 times and change dynamically.
I want to know if XML to ABAP internal table is possible with DOM or does it need XSLT too.
I used the blog of Robert which uses DOM, but it I am unable to collect the data in internal table. The blog explains only how to wtite the out put to screen as element and value.
I want to know if XML to ABAP internal table is possible with DOM or do I need XSLT too? I am confused please help.
Any help will be highly appreciated.
Regards,
Jessica SamHello Jessica
Why not using the DOM itself for processing?
Below you see the post-processing coding which I use to add the interchange control number (ICN) into an EDI message (which at this stage is still an XML-EDI stream). This is done on SAP-XI yet on the ABAP stack so you could use this approach on your R/3 system as well.
method POSTPROCESSING.
* Post-Processing of outbound EDI invoices & dispatch advices
me->map_icn( ).
endmethod.
method MAP_ICN.
* define local data
DATA: lo_node TYPE REF TO if_ixml_node,
ld_name TYPE string,
ld_value TYPE string,
ld_error_code type MPG_ERRCODE,
** ld_control_number TYPE char13,
ld_rc TYPE i,
ld_msg TYPE string. " bapi_msg.
DATA: ld_interface TYPE string.
DATA: incode TYPE REF TO if_ixml_node_collection.
LOG-POINT ID zedi
SUBKEY mc_subkey_method_trace.
ld_error_code = md_clsname.
* Get next interchange control number (ICN)
me->md_next_number = me->get_next_number(
id_nrobj = me->md_nrobj " Object (SNRO)
id_nrnr = me->md_nrnr ). " Number Range
CALL METHOD zcl_edi_uk_counter=>calculate_modulo_n09
EXPORTING
id_input = me->md_next_number
receiving
rd_output = me->md_next_number.
* Build ICN according to naming conventions agreed with EDI customer
me->md_icn = me->generate_icn( me->md_next_number ).
ld_value = me->md_icn. " type conversion to string
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020 ).
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
CLEAR: incode,
lo_node.
incode = me->mo_document->get_elements_by_tag_name( mc_d_0020_2 ). " element for ICN
lo_node = incode->get_item( index = 0 ).
CALL METHOD lo_node->set_value
EXPORTING
value = ld_value
RECEIVING
rval = ld_rc.
IF ( ld_rc NE 0 ).
CONCATENATE 'Error [' mc_d_0020_2
']: Method SET_VALUE (IF_IXML_NODE)'
INTO ld_msg.
CONDENSE ld_msg.
me->mif_trace->trace2( message = ld_msg ).
RAISE EXCEPTION TYPE cx_mapping_fault
EXPORTING
* textid =
* previous =
error_code = ld_error_code
error_text = ld_msg.
** MESSAGE ld_msg TYPE 'A'.
ENDIF.
* define local data
DATA: ls_record TYPE mpp_dynamic.
CLEAR: ls_record.
ls_record-namespace = mc_dynamic_namespace.
ls_record-name = mc_icn.
ls_record-value = ld_value.
mif_dynamic->add_record( ls_record ).
endmethod.
In your case you would need to do a DO...ENDDO loop until you parsed all required nodes.
NOTE: ME->MO_DOCUMENT is of TYPE REF TO IF_IXML_DOCUMENT.
Regards
Uwe
Maybe you are looking for
-
I've got a 17" Mac Book Pro with Snow Leopard and Final Cut Studio 2 . Compressor 3 is only giving MOV-1 which are no use to me. So I've bought Compressor 4 from the App store which it says isn't compatible with the graphics card on my 2008 mbp. Can
-
Print too small to read from printer with Page shrink on 30%
When printing some emails on Xerox 7225 the print is too small to read even with page shrink on 30%. latest email is from an AOL account and header lines do wrap. This problem is new.
-
my second Torch and it has an issue where it starts and when its done it reboots continuously. I had it flashed once but it did the thing again. does anyone have a solution to this. also I seen how memory cards are in need of repair too. I will t
-
How to pass value from one method to another method
Hi all, I have created a funtion module and i am calling this function module inside a method and it is exporting some value in a table, now i have to pass table value to another method where i have do some thing based upon this values. I think there
-
Upgraded to iOS 8.3 on iPad Mini, using Mavericks and iTunes 12,1,2,27 on early 2008 MacPro Can't add pdf books to iBooks like i used to . I normally use the add to library command to achieve this but books don't show up Following numerous tries and