Updating XML values with DOM
Guys,
I have XML that looks like this:
<datasheet>
<row num="1">
<dept>test</dept>
<code>test</code>
<prints>test</prints>
<origs>test</origs>
<sf>test</sf>
<price>test</price>
<description>test</description>
</row>
<row num="2">
<dept>asdf</dept>
<code>adad</code>
<prints>asdf</prints>
<origs>adf</origs>
<sf>asdf</sf>
<price>asdf</price>
<description>asdf</description>
</row>
</datasheet>
I need to update this info useing DOM, can you help me out. I know how to update single fields but not when they are displayed like this.
document.getElementsByTagName("department").item(0).getFirstChild().setNodeValue("COLOR2");
can you help?
So if it is NULL then we and and then if there is a record we just update like this rigth?
NodeList nl=document.getElementsByTagName("row");
for(int i=0; i<nl.getLength(); i++){
if(((Element)nl.item(i)).getElementsByTagName("dept").item(0).getFirstChild() == null){
((Element)nl.item(i)).getElementsByTagName("dept").item(0).appendChild(document.createTextNode("tagtext"));
else {
((Element)nl.item(i)).getElementsByTagName("dept").item(0).getFirstChild().setNodeValue("COLOR2");
Similar Messages
-
Updating XML file using DOM parser
Hi,
Can someone help me, how to update following XML file using DOM parser.
The following is my XML file.
<students>
<student>
<id>1</id>
<name>abc</name>
</student>
<student>
<id>2</id>
<name>xyz</name>
</student>
<student>
<id>3</id>
<name/>
</student>
<student>
<id>4</id>
<name>ijk</name>
</student>
<student>
<id>5</id>
<name></name>
</student>
</students>Consider, I will input 2 fields, ie., id & name. For the matching Id, the name has to be updated.
Though, I have achieved this, but I am unable to update the value for 3rd record, & 5th record ie., id=3 & id=5. Since, these are blank.
Thanks.Some <name> elements have a child node which is a text node. From what you say it appears you know how to change those text nodes.
The other <name> elements don't have any child nodes. But you want one. This suggests to me that you need code that creates a text node and adds it to the <name> element as its child. -
Program updating the value with succeeding 0
Hi
We have got a problem.
We have developed a program to update the value of the condition type. The upload file will have the SO, line item, condition type and value.
In the background, the sales order change BAPI is called and the value of the condition type is updated. There is no bug in the program for this functionality with reference to the problem.
When I upload, the value is getting uploaded correctly. But for some users, the value is updated with an additional 0 at the end. For example if 78 is the value of a condition type, the update happens as 780. The strange behaviour is that if I take that user id and password and upload in my laptop, the value is correctly uploaded without any addtional 0.
We have checked the user profile of all the problamatic users. They are fine. The xls sheet decimal notation is checked and they are also fine. There is no bug in the program, as it is working fine for many users.
What else should I be checking to solve this issue. An ABAPer advised to check the GUI level difference. I dont know how to do that but there should not be any such difference in the GUI versions for the users.
Can somebody put some light on this issue.Hi Navaneetha,
The Excel version is the same for you and the user?
Can the same be debugged and rectified?
Regards
Saurabh -
Hi,
I would like to know if its possible to insert or update
existing data of a XML file with flash?
And how can I do it?This code have two procedures or functions the createXML is
called first this one asks for the variable send using get called
fileName (Append this variable to the page request). The function
called writeToFile opens the file and writes to it.
Form flash you need to create the xmlfile and call the
sendAndLoad method. -
I have a XML file i need to parse. Can please someone give me a hint how to do this(please include code). Please note that im a new in XML and my DOM structure knowledge in limited(im confused from all the tutorials).
XML code:
<Vitals>
<Hostname>sometest</Hostname>
<IPAddr>sometest</IPAddr>
<Kernel>sometest</Kernel>
<Uptime>sometest</Uptime>
<Users>sometest</Users>
<LoadAvg>sometest</LoadAvg>
</Vitals>
<Network>
<NetDevice>
<Name>lo</Name>
<RxBytes>10425010</RxBytes>
<TxBytes>10425010</TxBytes>
<Errors>0</Errors>
<Drops>0</Drops>
</NetDevice>
<NetDevice>
<Name>eth0</Name>
<RxBytes>627976843</RxBytes>
<TxBytes>2394415516</TxBytes>
<Errors>271</Errors>
<Drops>0</Drops>
</NetDevice>
</Network>
So far ima at this step:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse( new File("NewFile.xml") );Just as simple text in console.
Please give me the code.
Is there any diference in document (DOM) if you create it with DFD or w/h ?
So far i have this code, but it dosnt work for me(i get nothing as output:
document = builder.parse( new File("NewFIle.xml") );
NodeList list = document.getElementsByTagName("coffee");
// Loop through the list.
for (int k=0; k < list.getLength(); k++) {
Node thisCoffeeNode = list.item(k);
Node thisNameNode = thisCoffeeNode.getFirstChild();
if (thisNameNode == null) continue;
if (thisNameNode.getFirstChild() == null) continue;
if (! (thisNameNode.getFirstChild() instanceof org.w3c.dom.Text)) continue;
String data = thisNameNode.getFirstChild().getNodeValue();
System.out.println(data);
} -
XML parsing a spesific value with DOM
Hi guys.
I have the following xml file:
<channel>
<title>Java Technology Headlines</title>
<link></link>
<description>Technical content and news from java.sun.com, the premier source of information about the Java platform.</description>
<language>en-us</language>
<image>
<title>java.sun.com</title>
<url>http://developers.sun.com/im/logo_java_grey.gif</url>
<link></link>
<width>144</width>
<hight>40</hight>
<description>Visit java.sun.com</description>
</image>
<item>
<title>Implementing Service-Oriented Architectures (SOA) with the Java EE 5 SDK</title>
<link>http://java.sun.com/developer/technicalArticles/WebServices/soa3/?feed=JSC</link>
<description>This article presents concepts and language constructs needed to develop a Service-Oriented Architecture composite application in Java EE 5. It then describes an example application designed to solve a business problem.</description>
<date></date>
</item>
<item>
<title>2006 JavaOne Highlights!</title>
<link>http://java.sun.com/javaone/sf/?feed=JSC</link>
<description>In It's a Wrap, read about the doings that kept 14,000 attendees percolating. Winner's Circle lists who won the various drawings. And Incoming T-Shirt! Duck! celebrates the Gosling-MythBusters' Wow factor.</description>
<date></date>
</item>
<item>
<title>Visit us at JavaOne!</title>
<link>http://java.sun.com/javaone/sf/?feed=JSC</link>
<description>We are at the 2006 JavaOne conference this week. Find out about the latest happenings, including session coverage, announcements, articles, blogs, photos, and more. Check out all the JavaOne action at java.sun.com/javaone/sf.</description>
<date></date>
</item>
</channel> and the following java class.
public class SimpleDOMExample
public SimpleDOMExample()
private static void scanDOMTree(Node node)
int type = node.getNodeType();
switch (type)
case Node.ELEMENT_NODE:
//System.out.println("Element: " +node.getNodeName());
if(node.getNodeName().equals("channel")&&node.getNodeName().equals("title"))
//&& node.getNodeName().equals("title"))
Node fc = node.getFirstChild();
//Node sc = fc.getNextSibling();
System.out.println("the tithe: "+ fc.getNodeValue());}
if(node.getNodeName().equals("link")){
// if ( node.getNodeName().equals("title") )//&& node.getNodeName().equals("title")
Node fc = node.getFirstChild();
//Node sc = fc.getNextSibling();
System.out.println("the url: "+ fc.getNodeValue());}
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++)
Node attr = attrs.item(i);
//System.out.println("Attribute: " +attr.getNodeName() + "=\"" + attr.getNodeValue());
NodeList children = node.getChildNodes();
if (children != null)
int len = children.getLength();
for (int i = 0; i < len; i++)
scanDOMTree(children.item(i));
break;
case Node.DOCUMENT_NODE:
scanDOMTree(((Document)node).getDocumentElement());
break;
case Node.ENTITY_REFERENCE_NODE:
//System.out.print("this &"+node.getNodeName()+";");
break;
case Node.TEXT_NODE:
// System.out.println("TEXT: " + node.getNodeValue().trim());
break;
public static void main(String argv[])
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
Document document = null;
try
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse( new File("java.xml"));
catch (Exception e)
e.printStackTrace();
if(document!=null)
scanDOMTree(document);
}The questions i have are really simple.
1) I am trying to get a specific value from the xml.
for example the <title> after <channel> but i want only this title not the others as well. I can all the titles but i cant get it right for returning only the first. What am i doing wrong?
2) i also want to parse the same values that are in the <item> for all 3 items but when i am using the
if(node.getNodeName().equals("link")){
Node fc = node.getFirstChild();
System.out.println("the link: "+ fc.getNodeValue());}i get a nullPointerException because the first link is empty under the <title>. If i change it to <description> it works fine.
The fact is that i dont know how to point it to look a specific tags like only in <item>
I have some comments in there of the different things i tried...
Any suggestions??? Pleaseeeee.... :)
Thx in advance...thx for the replay
1) i thought of using xpath but wanted to know how to do it over DOM
2) i mean that the 3 <item> have other element inside like that:
<item>
<title>Implementing Service-Oriented Architectures (SOA) with the Java EE 5 SDK</title>
<link>http://java.sun.com/developer/technicalArticles/WebServices/soa3/?feed=JSC</link>
<description>This article presents concepts and language constructs needed to develop a Service-Oriented Architecture composite application in Java EE 5. It then describes an example application designed to solve a business problem.</description>
<date />
</item>and all of them have <title>, <link> etc. I want to get the same values(eg. <title>) from all the 3 <item> and not including the <title> in the begining of xml
3) i am a professional child.....joke....
try to get to your sensitive side...thats way. -
Updating XML document using DOM only updates in memory
I am trying to update an element value but it only gets updated in the memory and displayed. It does not physically change the xml document when I look after running the program.
Here is the code I am trying to run :
Please let me know what I am doing wrong.
static private Document findReplace(Document document, String elementName,
String valueToFind, String valueToReplace)
int i;
int k;
NodeList children;
Element docRoot= document.getDocumentElement(); // get root
NodeList elements = docRoot.getElementsByTagName(elementName);
if (elements !=null)
for (i=0;i<elements.getLength(); i++)
if (elements.item(i).hasChildNodes())
children = elements.item(i).getChildNodes();
for(k=0;k<children.getLength(); k++)
if (children.item(k).getNodeType() ==
org.w3c.dom.Node.TEXT_NODE){
if(children.item(k).getNodeValue().equals(valueToFind))
children.item(k).setNodeValue(valueToReplace);
Thanks !Document document;
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(new File
(c:/output/outputXml.xml));
transformer.transform(source, result); -
How do I change elements values with DOM?
Hi, I'm trying to get to understand the DOM tutorials but I'm struggling with some things.. Basically I need to take an xml structure, read it and then change it to another xml structure. For instance, if I have the html sentence:
<p id="id10">One flight was found </p>
I would like to change it to a vxml sentence like
<vxml:prompt vxml:id="id10" vxml:bargein="false">One flight was found.</vxml:prompt>
And I need to do that to an entire file. I can read the html with the DOM (I'm following the http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/index.html tutorial) and show it without troubles, but I don't know and I can't find the functions that would allow me to modify the values. By values I mean both the element tags such as converting <p>..</p> to <prompt>..</prompt> and the attributes (like the id attribute). Could anybody help me here please?Thanks for that, but still can't do it. I'm using Xerces as you suggested. The following chunk is not actually what I need to do but I can't manage to get it working either. Shouldn't this:
Document doc= new DocumentImpl();
Element item = doc.createElement("name");
item.setNodeValue("nameChanged");
change the <name> tag to a <nameChanged> tag? When I output it it's still <name>.
I'm getting awfully confused with all the factories and models (yes, sorry, quite a newcomer, but I still need to do this somehow). If the following task is not too long/troublesome, could somebody please help me out with the code? Imagine you have a file with the content:
<label id="1">Hello</label>
and using xerces you want to create another file, without changing the first one, with the content:
<anotherLabel id="1">Hello<anotherLabel>
Edited by: victorNik on Sep 13, 2007 6:02 AM -
Hi All-
I am trying to replace a value from web.xml with one in a weblogic deployment plan. I deployed the application on WL 10.3.2 and used the deployment plan below. No matter what I do it doesn't seem to want to take the value.
web.xml:
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>TokenGroup</param-name>
<param-value>oldvalue</param-value>
</context-param>
</web-app>
Deployment Plan:
<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd"
global-variables="false">
<application-name>APPName</application-name>
<variable-definition>
<variable>
<name>TokenGroup</name>
<value>Key123456</value>
</variable>
</variable-definition>
<module-override>
<module-name>APPName.war</module-name>
<module-type>war</module-type>
<module-descriptor external="false">
<root-element>web-app</root-element>
<uri>WEB-INF/web.xml</uri>
<variable-assignment>
<name>TokenGroup</name>
<xpath>/web-app/context-param/[param-name="TokenGroup"]/param-value</xpath>
<operation>replace</operation>
</variable-assignment>
</module-descriptor>
</module-override>
</deployment-plan>
I've also tried other formats for the xpath such as:
/web-app/context-param/{param-name="TokenGroup"}/param-value
/web-app/context-param[param-name="TokenGroup"]/param-value
Any ideas why this doesnt work?
Thanks,
Joe"web.xml"
<?xml version='1.0' encoding='WINDOWS-1252'?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<context-param>
<param-name>name</param-name>
<param-value>Joe</param-value>
</context-param>
<context-param>
<param-name>password</param-name>
<param-value>password</param-value>
</context-param>
<servlet>
<servlet-name>ParameterServlet</servlet-name>
<servlet-class>ParameterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ParameterServlet</servlet-name>
<url-pattern>/ParameterServlet</url-pattern>
</servlet-mapping>
</web-app>
ParameterServlet
import java.io.IOException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ParameterServlet extends HttpServlet {
private String dbName = "";
private String dbPassword = "";
public void init(ServletConfig config) throws ServletException {
super.init(config);
ServletContext context = getServletContext();
dbName = context.getInitParameter("name");
dbPassword = context.getInitParameter("password");
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException {
ServletOutputStream out = res.getOutputStream();
res.setContentType("text/html");
out.println("<html><head><title>Basic Servlet</title></head>");
out.println("<body>Database username is <b>" + dbName);
out.println("</b><br>Database password is <b>" + dbPassword + "</b>");
out.println("</body></html>");
"Plan.xml"
<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd" global-variables="false">
<application-name>virtual</application-name>
<variable-definition>
<variable>
<name>name</name>
<value>akshay1</value>
</variable>
<variable>
<name>password</name>
<value>koul1</value>
</variable>
</variable-definition>
<module-override>
<module-name>virtual</module-name>
<module-type>war</module-type>
<module-descriptor external="false">
<root-element>web-app</root-element>
<uri>WEB-INF/web.xml</uri>
<variable-assignment>
<name>name</name>
<xpath>/web-app/context-param/[param-name="name"]/param-value</xpath>
<operation>replace</operation>
</variable-assignment>
<variable-assignment>
<name>password</name>
<xpath>/web-app/context-param/[param-name="password"]/param-value</xpath>
<operation>replace</operation>
</variable-assignment>
</module-descriptor>
</module-override>
<config-root>C:\DOCUME~1\user\LOCALS~1\Temp\user\.\config\deployments\virtual\plan</config-root>
</deployment-plan>
It works for me... I think your "web.xml" is causing the issue.
Try replacing
<?xml version = '1.0' encoding = 'windows-1252'?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
with
<?xml version='1.0' encoding='WINDOWS-1252'?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Hope this helps.
-Akshay -
How to insert or update comparing values with two or more table
Hai All
I have three or four table in my database.
Table 1 Dailattend is the main table here i need to insert or update my data and the fieds are
Emplcode number,attdate date, intime date,intrin date ,introut date, outtime date are the fields
Table 2 acclempbarcode the fields are
emplcode number ,barcode number ....etc
so now my data is in text format and i have broke the date like this
0011221100112200100320100815
First 16 is barcode and next 8 is date and 4 is time and i have created a temp table and store the date and move to main table
My problem is the main table dailattend has no barcode so when i am going to insert or update i need to check whether the barcode is match with the emplcode in the main table
How can i write insert or update statement
The data is like this
00110022 is barcode,10-03-2010 is my date and 0815 is time so i need to insert into dailattend table so now i have emplcode in dailattend table so i need to compare the barcode belong the emplcode in the another table and i need to insert in the dailattend table
Pls give me some solution with example
Regards
Srikkanth.Mtry somthing like this
create table t1
as
select '0011221100112200' barcode,to_date('100320100815','ddmmyyyyhh24mi') dt
from dual
create table barcodetbl
emplcode varchar2(2000)
barcode varchar2(2000)
datetime date
merge into barcodetbl bc
using( select * from t1) x
on
(bc.barcode = x.barcode)
when matched
then update
set datetime = x.dt
when not matched
then
insert (emplcode,barcode,datetime)
values(1,x.barcode,x.dt)
/didn't realize that barcode is not in the main table.
something along the lines
Table 1 Dailattend is the main table here i need to insert or update my data and the fieds are
Emplcode number,attdate date, intime date,intrin date ,introut date, outtime date are the fields
Table 2 acclempbarcode the fields are
emplcode number ,barcode number ....etc
merge into dailattend bc
using( select * from t1, acclempbarcode ac where t1.barcode = ac.barcode) x
on
(bc.emplcode = x.emplcode)
when matched
then update
set datetime = x.dt
when not matched
then
insert (emplcode,datetime)
values(1,x.dt)
/Alvinder
Edited by: alvinder on Mar 23, 2010 3:50 PM -
(updating xml value)adding an element in an xml type column
Hi all,
i hava a table that contains an xml-Type column (non schema based)
i have inserted some data in it
table:(id,xmlcolumn)
ex:
insert into t1 values(1,'<Chapters>
<Chapter>ch1<Chapter>
<Chapter>ch2<Chapter>
</Chapters>')
i need to add a new Chapter: <Chapter>ch3</Chapter>
for the result of xml instance in the table to be:
<Chapters>
<Chapter>ch1<Chapter>
<Chapter>ch2<Chapter>
<Chapter>ch3<Chapter>
</Chapters>
plz if any one colud helpSQL> DECLARE
2 l_xml XMLTYPE := XMLTYPE('<Chapters>
3 <Chapter>ch1</Chapter>
4 <Chapter>ch2</Chapter>
5 </Chapters>');
6 l_xsl XMLTYPE;
7 l_new_node VARCHAR2(100) := '<Chapter>ch3</Chapter>';
8 BEGIN
9 dbms_output.put_line('Before adding node:');
10 dbms_output.put_line('----------------------------------------------------------------');
11 dbms_output.put_line(l_xml.getStringVal());
12 dbms_output.put_line('----------------------------------------------------------------');
13 l_xsl := XMLTYPE('<?xml version="1.0"?>' ||
14 '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"' ||
15 ' version="1.0"' || ' result-ns=""' || ' indent="no">' ||
16 '<xsl:output method="xml" media-type="text/xml" indent="no"/>' ||
17 '<xsl:template match="/">' ||
18 '<' ||l_xml.getRootElement() || '>' ||
19 ' <xsl:for-each select="/' || l_xml.getRootElement() ||'/Chapter">' ||
20 '<xsl:copy-of select="." />' ||
21 '</xsl:for-each>' ||
22 l_new_node ||
23 '</' || l_xml.getRootElement() || '>' ||
24 '</xsl:template>' ||
25 '</xsl:stylesheet>');
26 l_xml := l_xml.Transform(l_xsl);
27 dbms_output.put_line('After adding node:');
28 dbms_output.put_line('----------------------------------------------------------------');
29 dbms_output.put_line(l_xml.getStringVal());
30 dbms_output.put_line('----------------------------------------------------------------');
31 END;
32 /
Before adding node:
<Chapters>
<Chapter>ch1</Chapter>
<Chapter>ch2</Chapter>
</Chapters>
After adding node:
<Chapters>
<Chapter>ch1</Chapter>
<Chapter>ch2</Chapter>
<Chapter>ch3</Chapter>
</Chapters>
PL/SQL procedure successfully completed.
SQL> -
Extracting XML values with namespace
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...Thanks, BluShadow!
added:
What if the structure of the XML is not always the same? Suppose that <aa:USER_INFO> sometimes contains subnode <aa:AUX>.
WITH t as (select XMLTYPE('
<RECSET xmlns:aa="http://www.w3.org">
<aa:REC>
<aa:COUNTRY>1</aa:COUNTRY>
<aa:POINT>1800</aa:POINT>
<aa:USER_INFO>
<aa:USER_ID>1</aa:USER_ID>
<aa:TARGET>28</aa:TARGET>
<aa:STATE>6</aa:STATE>
<aa:TASK>12</aa:TASK>
<aa:AUX>
<aa:AUX1>111</aa:AUX1> <aa:AUX2>222</aa:AUX2>
</aa:AUX>
</aa:USER_INFO>
<aa:USER_INFO>
<aa:USER_ID>5</aa:USER_ID>
<aa:TARGET>19</aa:TARGET>
<aa:STATE>1</aa:STATE>
<aa:TASK>90</aa:TASK>
</aa:USER_INFO>
</aa:REC>
<aa:REC>
<aa:COUNTRY>2</aa:COUNTRY>
<aa:POINT>2400</aa:POINT>
<aa:USER_INFO>
<aa:USER_ID>3</aa:USER_ID>
<aa:TARGET>14</aa:TARGET>
<aa:STATE>7</aa:STATE>
<aa:TASK>5</aa:TASK>
<aa:AUX>
<aa:AUX1>333</aa:AUX1>
</aa:AUX>
</aa:USER_INFO>
</aa:REC>
</RECSET>') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task, z.aux1, z.aux2
from t
,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
'/RECSET/aa:REC'
PASSING t.xml
COLUMNS country NUMBER PATH '/aa:REC/aa:COUNTRY'
,point NUMBER PATH '/aa:REC/aa:POINT'
,user_info XMLTYPE PATH '/aa:REC/*'
) x
,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
'/aa:USER_INFO'
PASSING x.user_info
COLUMNS user_id NUMBER PATH '/aa:USER_INFO/aa:USER_ID'
,target NUMBER PATH '/aa:USER_INFO/aa:TARGET'
,state NUMBER PATH '/aa:USER_INFO/aa:STATE'
,task NUMBER PATH '/aa:USER_INFO/aa:TASK'
,aux XMLTYPE PATH '/aa:USER_INFO/*'
) y
,XMLTABLE(XMLNAMESPACES('http://www.w3.org' as "aa"),
'/aa:AUX'
PASSING y.aux
COLUMNS aux1 NUMBER PATH '/aa:AUX/aa:AUX1'
,aux2 NUMBER PATH '/aa:AUX/aa:AUX2'
) z;This query returns only 2 rows. I'd like to have 3 rows returned :) 3 rows are returned when I add an empty <aa:AUX> node to the data but I wants to have 3 rows when the <aa:AUX> is missed also. -
Update XML files with a PHP form...
Hi,
I would like to know if its possible to update or insert data
to XML files from a PHP form? And how can I do it? Basically i want
to create a backoffice for my XML Flash slide show.
Can anyone help me?Indirectly, I suppose. In that you'd have to handcode
verything. There's
nothing built-in to DW to accomplish this task. The simplest
way of doing it
is to use the FSO to write out the XML to an XML file.
Jules
http://www.charon.co.uk/charoncart
Charon Cart 3
Shopping Cart Extension for Dreamweaver MX/MX 2004 -
Update XML files with HTML forms...
Hi,
I would like to know if its possible to update or insert data
to XML files from a HTML form? And how can I do it?
Does dreamweaver have any extension that does this?hi bregent!
im using php.
i have a xml flash slide show script, and i want to insert
this slide show on a site. No problem here, but i would like to
create a backoffice were i can update or insert the pictures of the
xml slide show.
can you help me on this? -
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?
Maybe you are looking for
-
How can i have 2 seperate phones on the cloud and not duplicate my contacts and stuff?
I have 2 iphones on my account, when I set up icloud it merged both contact files, notes, apps and everything else. the only way I have figured out how to keep it seperate is that I turned off the icloud sync on my wifes phone. isn't there a way to
-
Is there a way to edit the saved StartCfg.cfg file on a Linksys SRW switch?
I have a SRW248G4 switch that I want to edit the StartCfg.cfg file to use as a template for several new switches. The content of the startcfg.cfg file looks to be binary or mostly binary. Is there a way to get the switch to save and load the file i
-
Employee Hiring & Termination on a same date?
Hi Guys, 1.Can it possible to hire & terminate,hire & reassign a employee on a same day? 2. What the infotypes used for termination,we only used 713 it & use LIS9 Operation? 3.What the infotype modifier is used for? Thanks
-
How to run a BAPI in background mode?
Dear friends, I have a requirement [In the UI user can choose two options - run online or run backgroud] to run a BAPI (BAPI_SALESORDER_CHANGE) in background mode (background job) , does anybody know how to implement it? Thanks a lot!!
-
Can't uninstall or install a program on my laptop
Can't uninstall or install a program on my laptop: User account control popup and the yes option is deactivated