That specific XML node...
Hi
I have an ID document (CS3 - MAC - JavaScript) with a complex XML structure (about 700 nodes...).
I need to get the attributes of a specific node without making FOR statements because it takes a long time.
Basically every node in the XML structure has 5 attributes.
One of those is the ID.
Is it possible to get the node knowing the ID value?
Thanks anticipately.
> Is it possible to get the node knowing the ID value?
Take a look at the XML.xpath() method. That's it's purpose. The version in
Adobe's interpreters will choke on more complicated expressions, but looking for
nodes with a particular attributes should be something it can handle.
Similar Messages
-
How to get a value from Specific XML Node
Hi all,
I'm just trying to introduce to XMLType and see the potencialities of that.
DB version:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
CORE 10.2.0.5.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.5.0 - Productio
NLSRTL Version 10.2.0.5.0 - Production
I'm a table with just one CLOB field:
CREATE TABLE asm_test
(doc XMLType NOT NULL)
XMLTYPE doc STORE AS CLOB;
Then i've inserted the following XML data:
<?xml version="1.0" encoding="UTF-8" ?>
- <ReceiptDesc>
<appt_nbr>2142473</appt_nbr>
- <Receipt>
<dc_dest_id>401</dc_dest_id>
<po_nbr>2142473</po_nbr>
<document_type>P</document_type>
<asn_nbr />
- <ReceiptDtl>
<item_id>509720</item_id>
<unit_qty>83.0000</unit_qty>
<receipt_xactn_type>R</receipt_xactn_type>
+ <receipt_date>
<year>2012</year>
<month>09</month>
<day>17</day>
<hour>15</hour>
<minute>33</minute>
<second>49</second>
</receipt_date>
<receipt_nbr>6902340</receipt_nbr>
<container_id>1</container_id>
<to_disposition>ATS</to_disposition>
<user_id>NTCPO01</user_id>
<catch_weight />
</ReceiptDtl>
- <ReceiptDtl>
<item_id>509740</item_id>
<unit_qty>17.0000</unit_qty>
<receipt_xactn_type>R</receipt_xactn_type>
+ <receipt_date>
<year>2012</year>
<month>09</month>
<day>17</day>
<hour>15</hour>
<minute>33</minute>
<second>49</second>
</receipt_date>
<receipt_nbr>6902344</receipt_nbr>
<container_id>1</container_id>
<to_disposition>ATS</to_disposition>
<user_id>NTCPO01</user_id>
<catch_weight />
</ReceiptDtl>
</Receipt>
</ReceiptDesc>
And then i have started to make some tests to retrieve data from.
SELECT EXTRACTVALUE(doc, '/ReceiptDesc/appt_nbr') FROM asm_test; -- got the correct value 2142473
SELECT EXTRACTVALUE(doc, '/ReceiptDesc/Receipt/dc_dest_id') FROM asm_test; ---- got the correct value 401
select count(*) from asm_jam_test d where (d.doc.getClobVal()) like '%NTCPO01%'; -- got 1
But i need to find a Specific data from XML (the main goal is to update a value inside XML).
If i try this:
select extract(doc, '/ReceiptDesc/Receipt/ReceiptDtl/item_id/text()').getstringVal() from asm_test
where existsNode(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr') = 1;
got: 509720509740 -- which are the concatenate of 2 Item_ids
when i try to find out the Item_id of specific receipt_nbr i got a NULL response.
select extract(doc, '/ReceiptDesc/Receipt/ReceiptDtl/item_id/text()').getstringVal()
from asm_test
where existsNode(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr') = 1 and
extract(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr/text()').getstringVal() = '6902340';
What i'm doing wrong or which is the best way to get data from XML?
Many thanks in advanceHi,
Thanks for providing db version and sample data in the first place.
Don't forget to use the {code} tags to preserve formatting.
Also, when posting XML, do not copy/paste directly from your browser as it retains +/- signs and therefore needs extra processing on our side.
select count(*) from asm_jam_test d where (d.doc.getClobVal()) like '%NTCPO01%'; -- got 1No, don't do it like that.
Use existsNode() function in this situation :
SQL> select count(*)
2 from asm_test
3 where existsNode(doc, '/ReceiptDesc/Receipt/ReceiptDtl[user_id="NTCPO01"]') = 1
4 ;
COUNT(*)
1
when i try to find out the Item_id of specific receipt_nbr i got a NULL response.Yes, that's because this :
extract(doc,'/ReceiptDesc/Receipt/ReceiptDtl/receipt_nbr/text()').getstringVal()returns :
69023406902344So obviously it cannot be equal to '6902340'.
When you have to deal with repeating nodes individually, use XMLTable function to break the structure into relational rows and columns.
The resultset you'll get acts as a virtual table (or inline view) you can then manipulate with SQL operations :
SQL> select x.*
2 from asm_test t
3 , xmltable(
4 '/ReceiptDesc/Receipt/ReceiptDtl'
5 passing t.doc
6 columns item_id varchar2(15) path 'item_id'
7 , receipt_nbr varchar2(15) path 'receipt_nbr'
8 ) x
9 ;
ITEM_ID RECEIPT_NBR
509720 6902340
509740 6902344
Now, you can just add a WHERE clause to filter the RECEIPT_NBR you require :
SQL> select x.item_id
2 from asm_test t
3 , xmltable(
4 '/ReceiptDesc/Receipt/ReceiptDtl'
5 passing t.doc
6 columns item_id varchar2(15) path 'item_id'
7 , receipt_nbr varchar2(15) path 'receipt_nbr'
8 ) x
9 where x.receipt_nbr = '6902340'
10 ;
ITEM_ID
509720
That can also be achieved with EXTRACTVALUE and a single XPath expression (assuming RECEIPT_NBR is unique) :
SQL> select extractvalue(
2 doc
3 , '/ReceiptDesc/Receipt/ReceiptDtl[receipt_nbr="6902340"]/item_id'
4 ) as item_id
5 from asm_test
6 ;
ITEM_ID
509720 -
How to select a specific XML node with XPath
Hi,
I'm trying to a select a specific node from my XML data using the XPath Builder. For example, say I have a process variable 'xmlData' with the
following contents:
User 1
101
User 2
102
I can successfully use the following expression to retrieve the name of
a specific user:
(/process_data/xmlData/users/user[userid='102'])/name
The problem is I need to use another process variable for the selection
key. For Example:
(/process_data/xmlData/users/user[userid=/process_data/@userId])/name
But this always returns null. I've tried surrounding /process_data/@userId
with single quotes, double quotes, and event {$..$}.
Any help would be greatly appreciated.
Thanks.Hi,
Thanks for the quick replies. I gave a bit of a bad example, as the
userid in my data is really a string, not a number.
A better example is:
User 1
user1
User 2
user2
I can get the following to work perfectly:
(/process_data/xmlData/users/user[userid='user2'])/name
but I can't get it to work with
/process_data/@userId = "user2"
(/process_data/xmlData/users/user[userid=/process_data/@userId])/name
Thanks. -
Add attribute to a XML node at a specific position
I have this XML :
var myNode:XML = <node attribute="123"/>
I know how to add an attribute to the node :
myNode.@otherAttribute = "abc";
But this adds the attribute to the end. What if I want to add it as the first attribute ? I would like to have :
<node otherAttribute="abc" attribute="123"/>
I know it is possible to add a child node to a specific position with insertChildAfter() or insertChildBefore() but I don't know if it's possible for an attribute.there's no native method for this, maybe you should create some functions for this. just like
private function setAttribute(node:XML, name:String, value:String, index:int = -1):void
var attrs:XMLList = node.attributes().copy(),
l:int = attrs.length();
if(index == -1 || index > l - 1)
node.@[name] = value;
else
delete node.@*;
var idx:int = 0;
for (var i:int = 0; i < l + 1; i++)
if(i == index)
node.@[name] = value;
else
var attr:XML = attrs[idx];
node.@[attr.name()] = attr.toString();
idx++;
and use it like this:
setAttribute(myNode, "otherAttribute", "abc", 0); -
Closing XML node that has been queried closes (crashes?) LabVIEW
Can someone confirm this observation with closing an XML node that has been searched with the XPath expression of "/" only? This can be reproduced with the shipped XML example "Query XML Document for a Single Node.vi". Change the XPath expression to just the forward slash and notice that LabVIEW will close (or crash?) when the VI is executed.
ThanksIt doesn't crash until the origional node is closed. In the example pic it is not unitl it reaches the last "close" does it crash. I also gets a valid node from the search. Also, the /* doesn't crash it but the Result XML is not the same.
I am attempting to teach myself some stuff on XML and XPath expressions and according to WC3:
/ selects the document root (which is always the parent of the document element)
Anyway, I don't ever plan on using / as a standalone search element but wasn't expecting the crash...
P.S. & FYI my overall purpose is to parse out data from XML files generated by TestStand. I need to mine some data...
Attachments:
Query XML Document.png 40 KB -
SQL Server Agent Failed to decrypt protected XML node
I'm getting the below error when trying to run sql server agent to run an SSIS package. I've updated folder security to allow sql server agent access, but cannot get the package to execute within SQL Management Studio. The package runs find in SSIS.
11.0.2100.60 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 12:12:00 PM Error: 2014-11-30 12:12:02.65 Code: 0xC0016016 Source: LoadStgProspects Description:
Failed to decrypt protected XML node "DTS:Password" with error 0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that
the correct key is available. End Error Error: 2014-11-30 12:12:03.88 Code: 0xC0016016 Source: LoadStgProspects Description: Failed to decrypt protected XML node "DTS:Password" with error
0x8009000B "Key not valid for use in specified state.". You may not be authorized to access this information. This error occurs when there is a cryptographic error. Verify that the correct key is available. End Error Error: 2014-11-30
12:12:04.74 Code: 0xC0209303 Source: LoadStgProspects Connection manager "Excel Connection Manager" Description: The requested OLE DB provider Microsoft.Jet.OLEDB.4.0 is not registered. If the 64-bit driver
is not installed<c/> run the package in 32-bit mode. Error code: 0x00000000. An OLE DB record is available. Source: "Microsoft OLE DB Service Components" Hresult: 0x80040154 Description: "Class not registered".
End Error Error: 2014-11-30 12:12:04.74 Code: 0xC020801C Source: Load prospect files Prospect xls [231] Description: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection
method call to the connection manager "Excel Connection Manager" failed with error code 0xC0209303. There may be error messages posted before this with more information on why the AcquireConnection method call failed. End Error Error:
2014-11-30 12:12:04.74 Code: 0xC0047017 Source: Load prospect files SSIS.Pipeline Description: Prospect xls failed validation and returned error code 0xC020801C. End Error Error: 2014-11-30 12:12:04.74
Code: 0xC004700C Source: Load prospect files SSIS.Pipeline Description: One or more component failed validation. End Error Error: 2014-11-30 12:12:04.74 Code: 0xC0024107 Source:
Load prospect files Description: There were errors during task validation. End Error Error: 2014-11-30 12:12:04.74 Code: 0xC00220DE Source: LoadStgProspects Description: Error
0xC0012050 while loading package file "C:\Users\Jim\Documents\Visual Studio 2010\Projects\SSISTraining\SSISTraining\LoadStgProspects.dtsx". Package failed validation from the ExecutePackage task. The package cannot run. . End Error DTExec:
The package execution returned DTSER_FAILURE (1). Started: 12:12:00 PM Finished: 12:12:04 PM Elapsed: 4.337 seconds. The package execution failed. The step failed.,00:00:04,0,0,,,,0Hi selfdestruct80,
According to your description, you created SSIS package and it works fine. But you got the error message when the SSIS package was called from a SQL Server Agent job.
According to my knowledge, the package may not run in the following scenarios:
The current user cannot decrypt secrets from the package.
A SQL Server connection that uses integrated security fails because the current user does not have the required permissions.
File access fails because the current user does not have the required permissions to write to the file share that the connection manager accesses.
A registry-based SSIS package configuration uses the HKEY_CURRENT_USER registry keys. The HKEY_CURRENT_USER registry keys are user-specific.
A task or a connection manager requires that the current user account has correct permissions.
According to the error message, the SSIS Package ProtectionLevel property to EncryptSensitiveWithPassword as ArthurZ mentioned. To solve the problem, you need to go to Command Line tab, manually specify the paassword in SQL Agent Job with the command like below:
/FILE "\"C:\Users\xxxx\Documents\SQL Server Management Studio\SSIS\Package.dtsx\"" /DECRYPT somepassword /CHECKPOINTING OFF /REPORTING E
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Map several records to different elements in the same xml node
Hi,
I am trying to map data from relational tables to elements as per my xml schema. One of my tables has several records that I need to map to different elements in the same xml node.
For example:
Customer_Id | Param_Id |Param_Name
212 | 1 |State
212 | 2 |Country
212 | 3 |ZipCode
I can not change the structure of this existing table and need to work with it.
How do I map the different params for a specific customer to my Customer node in the schema?
One option is to join on the parameters table several times, but there ought to be a better way!
PLEASE HELP!!!
Thanks,First I question the design that contains/allows 600 attributes on an element. They sound like they really should be elements in the XML.
Regardless, the following (NOT TESTED) should work for you (assuming you want to write one SQL with 600 columns)
CREATE OR REPLACE VIEW APPLICATION_XML
OF XMLTYPE
Element "LOAN_APPLICATION"
with object ID
substr(extractValue(object_value,'/LOAN_APPLICATION/APPLICATION_DATA/@CallID'),1,5)
AS
WITH parm_tb AS
SELECT MAX(DECODE(prv_valu, 1, prv_value)) BusinessType,
MAX(DECODE(param_id, 2, prv_value)) Product,
MAX(DECODE(param_id, 3, prv_value)) SomethingElse
FROM parameter_details
WHERE prv_pmh_header_id = 1
SELECT xmlElement
("APPLICATION_DATA",
xmlAttributes
p.prv_detail_id as "CallID",
p.PRV_PRM_PARAM_ID as "RandomID",
p.prv_value as AppInitDate
xmlElement
("PRODUCER_DATA",
xmlAttributes
parm_tb.BusinessType as "BusinessType" ,
parm_tb.Product as "Product"
FROM parameters_table p
WHERE p.PRV_PMH_HEADER_ID = 1 -
Hello,
I'm using J Developer/SOA Suite 11.1.1.6.0 and BPEL 2.0
I am trying to remove datetime nodes from xml, where the datetime value equals a certain value. So far I have the following BPEL code:
<assign name="RemoveEmptyDates">
<extensionAssignOperation>
<bpelx:remove>
<bpelx:target>$GetNewHires_GetWrittenOffersReadyForUpload_OutputVariable.parameters//*[ . instance of xsd:dateTime and xsd:dateTime(.) = xsd:dateTime('0001-01-01T00:00:00')]</bpelx:target>
</bpelx:remove>
</extensionAssignOperation>
</assign>
I have tried multiple variations of the predicate, but I can't seem to figure it out. Right now I am getting an error in J Developer that specifies it is expecting an "]" right after the "//*[." portion of the predicate. Any ideas on this would be greatly appreciated.
ThanksYou can't use spaces.
you have wrong this part of your text:
[ . instance of xsd:dateTime and xsd:dateTime(.) = xsd:dateTime('0001-01-01T00:00:00')]
check it. -
How to binding incoming xml node list to the tree control as dataProvider
Recently, I faced into one issue: I want to binding incoming xml node (it's not avaliable at start) list to the tree control as a dataProvider.
Since the incoming xml node list is not avaliable at beginning but I needs to bind it to the tree, so I create one virtual one in the xml, and prepare to remove it before the tree is shown. (ready for the actual node adding). But It did not work.
Please see the presudo-code here:
1. Model layer(CsModel.as)
public class CsModel
[Bindable]
public var treeXML:XML=<nodes><car label="virtualOne" id="1">
</car></nodes>;
(Here, I want to build binding relationship on the <car/> node,
one 'virtual/stub' node is set here with lable="virtualOne".
But this node will be deleted after IdTree
control is created completely.)
[Bindable]
public var treeData:XMLList =new XMLListCollection(treeXML.car);
2. view layer(treePage.mxml)
private var _model:CsModel = new CsModel();
private function addNode():void
var newNode:XML=<car/>;
newNode.@label="newOne";
newNode.@id=1;
_model.treeXML.appendChild(newNode);
private function cleanData():void
delete _model.treeXML.car;
<mx:VBox height="100%" width="100%">
<mx:Button label="AddNode" click="addNode()" />
<mx:Tree id="IdTree" labelField="@label"
creationComplete="cleanData()"
dataProvider="{_model}"/>
</mx:VBox>
3. Top view layer (App.Mxml)
<mx:application>
<treePage />
</mx:application>
For method: cleanData(),It's expected that when the treePage is shown, we first delete the virutalOne to provide one 'clear' tree since we don't want show virtualOne to the user. The virutalOne node just for building the relationship between treeData and treeXML at beginning. But the side effect of this method, I found, is that the relationship between treeXML and treeData was cut off. And this leads to that when I added new node (by click the 'addNode' button) to the xmlXML, the xmlData was not affected at all !
So Is there any other way to solve this issue or bind the incoming xml node list to the xmlListCollection which will be used as Tree control's dataProvider ?If u want to display the name : value then u can do like this
<xsl:eval>this.selectSingleNode("name").nodeName</xsl:eval> : <xsl:value-of select="name" /> -
Store XML node value into an array with node element name
Hi,
I have the following code that displays the node element with the
corresponding node value. I want to store the values in an array in
reference to the node name.
i.e.
XML (my xml is much bigger than this, 300 elements):
<stock>
<symbol>SUNW</symbol>
<price>17.1</price>
</stock>-----
would store the following:
*data[symbol] = SUNW;*
*data[price] = 17.1;*
Thanks in advance,
Tony
test.jsp
Here's my source code:
<html>
<head>
<title>dom parser</title>
<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="dombean.*" %>
</head>
<body bgcolor="#ffffcc">
<center>
<h3>Pathways Info</h3>
<table border="2" width="50%">
<jsp:useBean id="domparser" class="dombean.MyDomParserBean" />
<%
Document doc = domparser.getDocument("c:/stocks/stocks.xml");
traverseTree(doc, out);
%>
<%! private void traverseTree(Node node,JspWriter out) throws Exception {
if(node == null) {
return;
int type = node.getNodeType();
switch (type) {
// handle document nodes
case Node.DOCUMENT_NODE: {
out.println("<tr>");
traverseTree
(((Document)node).getDocumentElement(),
out);
break;
// handle element nodes
case Node.ELEMENT_NODE: {
String elementName = node.getNodeName();
//if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
//out.println("</tr>");
out.println("<tr><td>"+elementName+"</td>");
NodeList childNodes =
node.getChildNodes();
if(childNodes != null) {
int length = childNodes.getLength();
for (int loopIndex = 0; loopIndex <
length ; loopIndex++)
traverseTree
(childNodes.item(loopIndex),out);
break;
// handle text nodes
case Node.TEXT_NODE: {
String data = node.getNodeValue().trim();
//if((data.indexOf("\n") <0) && (data.length() > 0)) {
out.println("<td>"+data+"</td></tr>");
%>
</table>
</body>
</html>
{code}
*MyDomParserBean.java*
Code: package dombean;
{code:java}
import javax.xml.parsers.*;
import org.w3c.dom.*;
import java.io.*;
public class MyDomParserBean
implements java.io.Serializable {
public MyDomParserBean() {
public static Document
getDocument(String file) throws Exception {
// Step 1: create a DocumentBuilderFactory
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
// Step 2: create a DocumentBuilder
DocumentBuilder db = dbf.newDocumentBuilder();
// Step 3: parse the input file to get a Document object
Document doc = db.parse(new File(file));
return doc;
{code}
Edited by: ynotlim333 on Sep 24, 2007 8:41 PM
Edited by: ynotlim333 on Sep 24, 2007 8:44 PM
Edited by: ynotlim333 on Sep 24, 2007 8:45 PMI still need to store it in an array because its 300 elements in the XML stocks.
I've done the following but its not working, i'm getting error codes. I think its an easy fix. I'd also like to pass a String instead of a .xml document b/c my xml is stored inside a DB. Any suggestions on that?
<html>
<head>
<title>dom parser</title>
<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="org.*" %>
</head>
<body bgcolor="#ffffcc">
<center>
<h3>Pathways Info</h3>
<table border="2" width="50%">
<jsp:useBean id="domparser" class="org.MyDomParserBean" />
<%
Document doc = domparser.getDocument("c:/stocks/stocks.xml");
traverseTree(doc, out);
%>
<%!
public String element_store = null;
public String[] stock_data = new String[400];
private void traverseTree(Node node,JspWriter out) throws Exception {
if(node == null) {
return;
int type = node.getNodeType();
switch (type) {
// handle document nodes
case Node.DOCUMENT_NODE: {
out.println("<tr>");
traverseTree
(((Document)node).getDocumentElement(),
out);
break;
// handle element nodes
case Node.ELEMENT_NODE: {
String elementName = node.getNodeName();
element_store = elementName;
//if(elementName.equals("MOTHER-OCC-YRS-PREVIOUS")) {
//out.println("</tr>");
NodeList childNodes =
node.getChildNodes();
if(childNodes != null) {
int length = childNodes.getLength();
for (int loopIndex = 0; loopIndex <
length ; loopIndex++)
traverseTree
(childNodes.item(loopIndex),out);
break;
// handle text nodes
case Node.TEXT_NODE: {
String data = node.getNodeValue().trim();
if((data.indexOf("\n") <0) && (data.length() > 0)) {
out.println("<tr><td>"+element_store+"</td>");
out.println("<td>"+data+"</td></tr>");
stock_data[element_store]=data;
%>
</table>
</body>
</html> -
Using FGA in Oracle 9i on tables that store XML data
Hello,
Our company wishes to use FGA policies to log transaction data for updates that take place in our software (Web based software using Oracle 9i Enterprise Edition (9.2.0.6.0))
This is working just great for logging transaction information on all of our tables except for those that hold XML data. It seems that the XML code is causing an error as it attempts to write in to an audit entry. I have requested information on the specific errors that are being generated, and do not have the exact messages to post yet - but I was hoping that someone out here could comment on FGA and XML data logging, if this is even possible in 9i, or if particular add-ons or updates may need to be made to the database before this can be expected to function as desired.
Thank you in advance,
Sabrina Goodpaster
Database / Configuration Management Specialist
ENVISAGE Technologies, Corp.
1441 S. Fenbrook Lane
Bloomington, IN 47401Is the intent to audit tables containing XML or to audit changes to the XML? There is a huge difference.
Also, working in software as older than my car isn't helping you. How about applying a few patches or upgrading to something supported? -
Read a XML node value/attribute value from a CLOB
Hello,
I can write SQL/ - PL/SQL "straightforward" but now I have a problem what is to big for me. I hop that someone can help.
We create by code a xml structure and write these into the oracle database CLOB field. I'm sorry to say that a xml text structure is written into a clob in stead of a xmltype field. (it's a design failure?) It's a large xml structure. I believe I can't attach a file so I put at the end of this discussion a light example of the xml structure.
It's a xml with quartervalue's, so there are 35040 detail rows (24h * 4 * 365days). I want to accumulate the the attribute Amount value 9. The amount value is in the Detail node a attribute but at the end you can see that for the DST are also 4 value's, but these are not attribute value's but node value's. (In this case it are four value's in some cases there is one DST amount value.
Can somebody help me how to accumulate all the detail attribute value Amount with the node value Amount of the DST tag?
XML structure:
<?xml version="1.0"?>
<Message xmlns:ns1="http://automaticdealcapture/">
<BusinessDocument messageDateTime="2013-10-25T13:59:31+02:00" ediReference="LO-461967" messageName="New" businessSector="Z" documentFunction="Original">
<DocumentData>
<ns1:Adcs>
<ns1:Package>
<ns1:Deal>
<ns1:ProductCode>PWCODE</ns1:ProductCode>
<ns1:Action>NEW</ns1:Action>
<ns1:Memo1>MemoField</ns1:Memo1>
<ns1:Details>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="00:00:00" Timee="01:00:00" Amount="0.0153" Price="11.111"/>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="01:00:00" Timee="02:00:00" Amount="0.015" Price="22.222"/>
etc. 350040 detail rows.
</ns1:Details>
<ns1:DSTS>
<ns1:Year Val="2014">
<ns1:DST Period="1">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="2">
<ns1:Amount>0.0222</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="3">
<ns1:Amount>0.0444</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="4">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
</ns1:Year>
</ns1:DSTS>
</ns1:Deal>
</ns1:Package>
</ns1:Adcs>
</DocumentData>
</BusinessDocument>
</Message>From what I know, extracting the "Amount" values in the Details section and the "Amount" values in the DSTS section would be two different SELECT statements.
Both of these will use XMLTable() to extract the values.
BTW - If you need more information on this, post up in the XML/XML DB forum section for more complex help. (eg getting YEAR with the DSTS Amount values)
as far as XML size goes, I've seen oracle handle a 100MB XML document without problems.
(just understand, it will be 'slow')
This one will give you the Amount values from the DSTS section:
with xml_data as ( SELECT
XMLType('<?xml version="1.0"?>
<Message xmlns:ns1="http://automaticdealcapture/">
<BusinessDocument messageDateTime="2013-10-25T13:59:31+02:00" ediReference="LO-461967" messageName="New" businessSector="Z" documentFunction="Original">
<DocumentData>
<ns1:Adcs>
<ns1:Package>
<ns1:Deal>
<ns1:ProductCode>PWCODE</ns1:ProductCode>
<ns1:Action>NEW</ns1:Action>
<ns1:Memo1>MemoField</ns1:Memo1>
<ns1:Details>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="00:00:00" Timee="01:00:00" Amount="0.0153" Price="11.111"/>
<ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="01:00:00" Timee="02:00:00" Amount="0.015" Price="22.222"/>
</ns1:Details>
<ns1:DSTS>
<ns1:Year Val="2014">
<ns1:DST Period="1">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="2">
<ns1:Amount>0.0222</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="3">
<ns1:Amount>0.0444</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
<ns1:DST Period="4">
<ns1:Amount>0.0146</ns1:Amount>
<ns1:Price>33.333</ns1:Price>
</ns1:DST>
</ns1:Year>
</ns1:DSTS>
</ns1:Deal>
</ns1:Package>
</ns1:Adcs>
</DocumentData>
</BusinessDocument>
</Message>') as XMLDATA from dual
select Y.amount
from xml_data X,
XMLTable( XMLNAMESPACES( 'http://automaticdealcapture/' as "ns1"),
'/Message/BusinessDocument/DocumentData/ns1:Adcs/ns1:Package/ns1:Deal/ns1:DSTS/ns1:Year/ns1:DST'
passing X.XMLData
COLUMNS
amount Number PATH '/ns1:DST/ns1:Amount'
) Y;
Replace the XMLTable() with the one below to get the Amount from the Details section:
XMLTable( XMLNAMESPACES( 'http://automaticdealcapture/' as "ns1"),
'/Message/BusinessDocument/DocumentData/ns1:Adcs/ns1:Package/ns1:Deal/ns1:Details/ns1:Detail'
passing X.XMLData
COLUMNS
amount number PATH '/ns1:Detail/@Amount'
) Y; -
Using XSLT to extract value of a XML node with namespace
I have a XML source code here.
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:job="http://www.pageuppeople.com">
<channel>
<title>SMH Jobs</title>
<link>internalrecruitment.smhgroup.com.au/jobsrss.ashx?stp=di</link>
<description>A listing of jobs available here</description>
<item>
<title>eCommerce Optimisation Advisor</title>
<description>A new and exciting opportunity exists for an experienced eCommerce Advisor to join</description>
<job:location PUReferenceID="3711">Sydney - Inner Suburbs & CBD</job:location>
</item>
</channel>
</rss>
I want to use XSLT to extract value of a XML node with namespace <job:location>, and the returned value should be string 'Sydney - Inner Suburbs & CBD'. I tried a few XSL code below, but failed with error or nothing was returned.
<xsl:value-of select="job:location" disable-output-escaping="yes"/>
<xsl:value-of select="job/location" disable-output-escaping="yes"/>
<xsl:value-of select="job\location" disable-output-escaping="yes"/>
<xsl:value-of select="location" disable-output-escaping="yes"/>
This might be an easy question for you, but I would appreciate if anyone can help.Hi Suncorp IT Learner,
We need to tell the XSLT that some elements are in another namespace. Copy the xmls declarations for the prefixes you need to use. Then use the xsl format as:
<xsl: value-of select=”job:location/@PUReferenceID”/>
In following issue, Chriztian has a good explanation:
http://our.umbraco.org/forum/developers/xslt/33353-XSLT-reading-XML-attribute-value
Thanks,
Qiao Wei
TechNet Community Support -
Xml in JTree: how to not collpase JTree node, when renaming XML Node.
Hi.
I'm writing some kind of XML editor. I want to view my XML document in JTree and make user able to edit contents of XML. I made my own TreeModel for JTree, which straight accesses XML DOM, produced by Xerces. Using DOM Events, I made good-looking JTree updates without collapsing JTree on inserting or removing XML nodes.
But there is a problem. I need to produce to user some method of renaming nodes. As I know, there is no way to rename node in w3c DOM. So I create new one with new name and copy all children and attributes to it. But in this way I got a new object of XML Node instead of renamed one. And I need to initiate rebuilding (treeStructureChanged event) of JTree structure. Renamed node collapses. If I use treeNodesChanged event (no rebuilding, just changes string view of JTree node), then when I try to operate with renamed node again, exception will be throwed.
Is there some way to rename nodes in my program without collpasing JTree?
I'am new to Java. Maybe there is a method in Xerces DOM implementation to rename nodes without recreating?
Thanks in advance.I assume that "rename" means to change the element name? Anyway your question seems to be "When I add a node to a JTree, how do I make sure it is expanded?" This is completely concerned with Swing, so it might have been better to post it in the Swing forum, but if it were me I would do this:
1. Copy the XML document into a JTree.
2. Allow the user to edit the document. Don't attempt to keep an XML document or DOM synchronized with the contents of the JTree.
3. On request of the user, copy the JTree back to a new XML document.
This way you can "rename" things to the user's heart's content without having the problem you described. -
How to set the value in the xml node.
Hi
I am having the application PDF which can be submitted by user using the button. while submitting
i am using below code to set the value in the xml node.
xfa.data.assignnode("employee.id","123",0):
So its generating the xml like below.
<employee>.
<id>123</id>.
</name>
</employee>
Now i need to generate the xml like below.
<employee id= "123" >
</Name>
</employee>
So how to set/create the id node like above?
Advance Thanks.
Regards,
DhiyaneHi Dhiyane,
You will have to set the contains property if the id node to "metaData", that is;
xfa.data.assignNode("employee.id","123",0);
xfa.data.employee.id.contains = "metaData";
Very clumsy if you have a number of them, in which case you might want to look at using E4X.
Good luck
Bruce
Maybe you are looking for
-
My Blackberry Device got wet in Salt Water, How to extract the data from its Memory ?
I have forgotten my device in my pocket while swimming in Sea Water. Eventually , the device got water damaged , I've taken out the battery, used the hair drier and still didn't work. All My concern is how can I retrieve the data on my Device Memory.
-
Printing 5.5" x 8.5"daily calendar pages (2/page)
Augh! So frustrated!!! I'd like to just print my daily calendar pages at roughly 5.5" (W) x 8.5" (H), two pages per sheet of standard letter size paper, using landscape mode to fit them on 1 sheet of paper. I've tried everything I can think of, and e
-
How to reverse Internal Order Settlement Postings
Dear Sir, We have settled cost of an Internal Order to another Internal Order using Tcode KO88 . Due to some mistake , we want to reverse the posted settlement transactions . Pl guide us , how can we reverse the same . Regards B Mittal
-
Using my macbook pro whole day with the power adapter , will it affect my battery? Please help
-
Make the website play flash easier
we can always see websites play flash online, when I set up my own website, but I don't know flash very much I want to put my video on it, in order to do this easily, I use Flash Video MX to convert my Video to Flash, (almost all types of video)with