Delete an end (leaf) Node in an XML Document
I have an object type node, where each of them was a node of object type, which can contain a node of type object etc. I need to remove the last item and returns the new xml document, see example, any ideas?< id menuItem = "itemID" Graphic = "" name = "test01" text = "test01" > "
< id menuItem = "itemID" Graphic = "" name = "test01" text = "test01" > "
< id menuItem = "itemID" Graphic = "" name = "test01" text = "test01" > "
< id menuItem = "itemID" Graphic = "" name = "test01" text = "test01" > "
< / menuItem >
< / menuItem >
< / menuItem >
< / menuItem >
Thank you
Chester
public void removeEndNode(value:XML):XML {}
If (value.descendants("*").length () == 0) {}
return (value) XML;
} else {}
value.descendants("*") [value.descendants("*").length () - 2] = "";
return (value) XML;
}
}
Tags: Flex
Similar Questions
-
How to remove a node in an XML document
Hello
My flex plugin loads an XML document that is passed from the ExternalInterace. I have a list control that displays the data from the XML document.
The XML looks like:
< document >
< response >
< objectlist >
< list type = "type" >
< object type = "type" name = "Value name" id = "GUID value1" >
< params >
.........
.........
< params >
< / object >
<! - several items in this list - >
< / list >
< / objectlist >
< / answer >
< / document >
I set the dataProvider of the list to xmlDoc.response.objectlist.list.object
Here, I want to delete one of the object before displaying the data nodes (in other words, I don't want one of the nodes in the document XML should appear in the list).
How can I do this? I couldn't find a way to remove a node in the XML api.
-GerardYou can either use the operator 'delete ':
delete xmlDoc.response.objectlist.list.object [5]
When the object to delete can be the fifth down (you need to play with your xml code in debugging down actual values) or convert xmlListCollection. The xmlListCollection provides easy methods to remove the offending nodes or you can provide a function filterFunction for the collection that allows you to "hide" the node. -
XML document lack of implementation in the form after adding the node
Hi all
I'm adding a new node to my XML document using java.
After I add, when I print the doc, I can see the xml code is not properly 'indexed' or 'formatted' (with a step internal node within the parent node.)
I have put OutputKeys.INDEX that Yes. But I still have this problem.
Kindlly help me regarding this.
Thank you
Sabarisri. NAfter I add, when I print the doc, I can see that xml is not properly "indexed" (sic, "indented") or 'formatted' (with a step internal node within the parent node.)
It is indeed a common place of what to get. Rarely these whitespace contravene semantic aspects of xml, but it's annoying to the human eye. The OutputKeys.INDENT on the transformer fixing certainly wouldn't heal and makes it worse.
If the lack of alignment gets enough wide, sometimes I use a custom xsl file to put an order of it. This is how the xsl looks like: it is just a slight development of an identity transformation. And I assume you are using jdk1.5 + packaged xerces and xalan.
Suppose to be called indenter.xsl, and put themselves in the working directory. Printing to a file may seem just that.
TransformerFactory tf = TransformerFactory.newInstance(); Transformer t = tf.newTransformer(new StreamSource("indenter.xsl")); //suppose the doc is the document parsed and edited in the memory, and outfile is the path to output file t.transform(new DOMSource(doc), new StreamResult(new FileOutputStream(outfile)));
I use xalan namespace to control the amount of space to indent. If you don't use of xalan, just leave these namespace declaration and the xalan:indent - amounted to and let the xsl processor using its default value.
If you prefer instead of writing your own small xsl utilities, you can maybe google (mainly in using key as pretty print or a utility called htmltidy with w3c) to clean the misaligned output. Or check the documentation on the xsl processor used, some processor could have custom method to do the same.
But cleaning may still run the risk of too interpret what can hold and is not. It is important to know what you finally want what to do and adjust according to your need.
Published by: tsuji on Sep 21, 2011 07:57
-
How to extract the node where the value of the node is the max in all of the XML document?
Hello
I have a transaction that refers to an xmltype in iRecruitment, containing multiple versions of the same node as follows:
(only for the example data)
{noformat} & lt; Transaction & gt;
& lt; data & gt;
& lt; ObjectVersionNumber & gt; 1 & lt; / object_version_number & gt;
& lt; EO & gt;
& lt; Attribute1 & gt; A & lt; / Attribute1 & gt;
& lt; Attribut2 & gt; B & lt; / attribut2 & gt;
& lt; /EO & gt;
& lt; / data & gt;
& lt; data & gt;
& lt; ObjectVersionNumber & gt; 2 & lt; / object_version_number & gt;
& lt; EO & gt;
& lt; Attribute1 & gt; A & lt; / Attribute1 & gt;
& lt; Attribut2 & gt; C & lt; / attribut2 & gt;
& lt; /EO & gt;
& lt; / data & gt;
& lt; data & gt;
& lt; ObjectVersionNumber & gt; X & lt; / object_version_number & gt;
& lt; EO & gt;
& lt; Attribute1 & gt;? & lt; / Attribute1 & gt;
& lt; Attribut2 & gt;? & lt; / attribut2 & gt;
& lt; /EO & gt;
& lt; / data & gt;
& lt; / Transaction & gt; {noformat}
I can extract a value for FULL-TIME 1 or 2, is not a problem.
However, how can I go on the selection of a value of an attribute below FULL-TIME X, where X is the maximum value of FULL-TIME in any node in the XML document?
I tried to the last node corresponding to my way, but it is not always the case that the FULL-TIME max will correspond to this scenario.
Any help would be greatly appreciated!
Thank you very much, Pete
Published by: Pete Mahon on February 24, 2009 12:11Here's a way
SQL> set long 100000 SQL> with XML as ( 2 select XMLTYPE( 3 ' 4
5 6 ') OBJECT_VALUE 27 from dual 28 ) 29 select DATA, OVN 30 from XML, 31 XMLTable 32 ( 33 '/Transaction/data' 34 passing OBJECT_VALUE 35 columns 36 DATA XMLType path '.', 37 OVN number path 'ObjectVersionNumber' 38 ) 39 where OVN = ( select MAX(OVN) 40 from XML, 41 XMLTable 42 ( 43 '/Transaction/data' 44 passing OBJECT_VALUE 45 columns 46 OVN number path 'ObjectVersionNumber' 47 ) 48 ) 49 SQL> / DATA -------------------------------------------------------------------------------- OVN ----------1 78 11 12 13A 9B 102 1415 18 19 20A 16C 173 2122 25 26? 23? 243 3 SQL>? ? -
Re-write the code DOM node with SQL - XML funtions
Hi friends,
Could you please help to re - write the code using the following SQl - XML functions
DECLARE
l_domdoc dbms_xmldom. DOMDocument;
l_xmltype XMLTYPE.
l_root_node dbms_xmldom. DOMNode;
l_departments_node dbms_xmldom. DOMNode;
l_dept_element dbms_xmldom. DOMElement.
l_dept_node dbms_xmldom. DOMNode;
l_name_node dbms_xmldom. DOMNode;
l_name_textnode dbms_xmldom. DOMNode;
l_location_node dbms_xmldom. DOMNode;
l_location_textnode dbms_xmldom. DOMNode;
l_employees_node dbms_xmldom. DOMNode;
l_emp_element dbms_xmldom. DOMElement.
l_emp_node dbms_xmldom. DOMNode;
l_emp_first_name_node dbms_xmldom. DOMNode;
l_emp_first_name_textnode dbms_xmldom. DOMNode;
l_emp_last_name_node dbms_xmldom. DOMNode;
l_emp_last_name_textnode dbms_xmldom. DOMNode;
BEGIN
-Create an empty XML document
l_domdoc: = dbms_xmldom.newDomDocument;
-Create a root node
l_root_node: = dbms_xmldom.makeNode (l_domdoc);
-Create a new node departments and add it to the root node
l_departments_node: = dbms_xmldom.appendChild (l_root_node
, dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Deptartments'))
);
FOR r_dept IN (SELECT dept.department_id
dept.department_name
loc.city
SERVICE dept
JOIN the loc site
ON loc.location_id = dept.location_id
WHERE dept.department_id IN (10.20)
)
LOOP
-For each folder, create a new item Dept with the service as an attribute ID.
- and add this new Dept element in the node of departments
l_dept_element: = dbms_xmldom.createElement (l_domdoc, "Dept");
dbms_xmldom.SetAttribute (l_dept_element, 'Deptno', r_dept. Department_id);
l_dept_node: = dbms_xmldom.appendChild (l_departments_node
dbms_xmldom.makeNode (l_dept_element)
);
-Each node Dept will get a node names that contains the name of the service as a text
l_name_node: = dbms_xmldom.appendChild (l_dept_node
, dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Name'))
);
l_name_textnode: = dbms_xmldom.appendChild (l_name_node
dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_dept.department_name))
);
-Each node Dept will also get a node to the location that contains the location (city) in the form of text
l_location_node: = dbms_xmldom.appendChild (l_dept_node
, dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Location'))
);
l_location_textnode: = dbms_xmldom.appendChild (l_location_node
dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_dept.city))
);
-For each Department, add a node of employees
l_employees_node: = dbms_xmldom.appendChild (l_dept_node
, dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, 'Employees'))
);
FOR r_emp IN (SELECT employee_id
first name
last_name
Employees
WHERE department_id = r_dept.department_id
)
LOOP
-For each folder, create a new item Emp with the employee as an attribute ID.
- and add this new element of the Emp to the employees node
l_emp_element: = dbms_xmldom.createElement (l_domdoc, 'Emp');
dbms_xmldom.SetAttribute (l_emp_element, "empid", r_emp.employee_id);
l_emp_node: = dbms_xmldom.appendChild (l_employees_node
dbms_xmldom.makeNode (l_emp_element)
);
-Each node emp will get a first name and a last name node that contains the first name and the last name text
l_emp_first_name_node: = dbms_xmldom.appendChild (l_emp_node
, dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, "FirstName"))
);
l_emp_first_name_textnode: = dbms_xmldom.appendChild (l_emp_first_name_node
dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_emp.first_name))
);
l_emp_last_name_node: = dbms_xmldom.appendChild (l_emp_node
, dbms_xmldom.makeNode (dbms_xmldom.createElement (l_domdoc, "LastName"))
);
l_emp_last_name_textnode: = dbms_xmldom.appendChild (l_emp_last_name_node
dbms_xmldom.makeNode (dbms_xmldom.createTextNode (l_domdoc, r_emp.last_name))
);
END LOOP;
END LOOP;
l_xmltype: = dbms_xmldom.getXmlType (l_domdoc);
dbms_xmldom.freeDocument (l_domdoc);
dbms_output.put_line (l_xmltype.getClobVal);
END;
/
Thank you and best regards,
Arun Thomas T
It's as simple as that:
SQL> select xmlserialize(document 2 xmlelement("Departments" 3 , xmlagg( 4 xmlelement("Dept" 5 , xmlattributes(d.department_id as "Deptno") 6 , xmlforest( 7 d.department_name as "Name" 8 , l.city as "Location" 9 ) 10 , xmlelement("Employees" 11 , ( 12 select xmlagg( 13 xmlelement("Emp" 14 , xmlattributes(e.employee_id as "empid") 15 , xmlforest( 16 e.first_name as "FirstName" 17 , e.last_name as "LastName" 18 ) 19 ) 20 ) 21 from hr.employees e 22 where e.department_id = d.department_id 23 ) 24 ) 25 ) 26 ) 27 ) 28 indent 29 ) 30 from hr.departments d 31 join hr.locations l on l.location_id = d.location_id 32 where d.department_id in (10,20) ; XMLSERIALIZE(DOCUMENTXMLELEMEN --------------------------------------------------------------------------------
Administration Seattle Jennifer Whalen Marketing Toronto Michael Hartstein Pat Fay -
I pushed cntrl alt delete push end treat a moment I have nothing, I don't see my arrow cursor cant access is almost anything. What process I end a how can I reopen a return to normal?
This all started because I get a warning about upgrading one pay for vista internet security 2010 alert... every 2 minutes it would be enterupt of me
Hello
Just in case there are persistent pieces of malware here is the method of complete elimination.
.exe question difficulty in the next message.Try Mode safe mode with networking - repeatedly, press F8 that you start.
The best two methods allow scanners to run and/or AV.exe out of the way or removing.
1.
CTRL SHIFT ESC - task manager OR right click on the taskbar - task managerProcess tab - complete the process on AV. EXE and continue with the uninstall Guide.
If necessary use start - computer or Windows Explorer to navigate to
C:\Program Malwarebytes Anti - Malware\mbam.exe or where it is installed - if
necessary right click on the shortcut of Malwarebytes - Properties - tab - target line to see where it
is installed.Right-click on it and rename it to ZZMbam.COM (or something different than now), then
Double-click it and run it like this. You can rename it back later. Do the same with others
programs as needed. Use this method for other necessary - DO NOT ASSUMER one
program removes all or that there is no other malware.---------------------------------------------------
2.
Another method is to use them:Use Process Explorer to "Suspend" the process will not stop
Then use AutoRuns to delete the malicious program startup items.
Now use UnLocker to delete the files in the malware.
You may need to do a file at a time.
Process Explorer - free
http://TechNet.Microsoft.com/en-us/Sysinternals/bb896653.aspxAutoRuns - free
http://TechNet.Microsoft.com/en-us/sysinternals/bb963902.aspxUnLocker - free (do not install the adaware Ebay)
http://www.Softpedia.com/get/system/system-miscellaneous/unlocker.shtmlAV.exe
==============================================
Vista Internet Security is just another name for these:
Win 7 Antispyware 2010 XP Internet Security 2010 and Vista Antivirus 2010 is rogue antivirus.
scams to get you to pay for them while they have no advantage at all.How to remove Vista Internet Security
http://www.bleepingcomputer.com/virus-removal/remove-antivirus-Vista-2010RENAME this as necessary to allow them to perform: (use .com instead of .exe)
It can be made repeatedly in Mode safe - F8 tap that you start, however, you must also run the
in the regular when windows you can.Download malwarebytes and scan with it, run MRT and add Prevx to be sure that he is gone. (If Rootkits
UnHackMe execution)Download - SAVE - go to where you put it-right on - click RUN AS ADMIN
Malwarebytes - free
http://www.Malwarebytes.org/Run the malware removal tool from Microsoft
Start - type in the search box-> find MRT top - right on - click RUN AS ADMIN.
You should get this tool and its updates via Windows updates - if necessary, you can download
here.Download - SAVE - go to where you put it-right on - click RUN AS ADMIN
(Then run MRT as shown above.)Microsoft Malicious - 32-bit removal tool
http://www.Microsoft.com/downloads/details.aspx?FamilyId=AD724AE0-E72D-4F54-9AB3-75B8EB148356&displaylang=enMicrosoft Malicious removal tool - 64 bit
http://www.Microsoft.com/downloads/details.aspx?FamilyId=585D2BDE-367F-495e-94E7-6349F4EFFC74&displaylang=enalso install Prevx to be sure that it is all gone.
Download - SAVE - go to where you put it-right on - click RUN AS ADMIN
Prevx - Home - free - small, fast, exceptional CLOUD protection, working with other security programs.
It is a single scanner, VERY EFFICIENT, if it finds something to come back here or use Google to see
How to remove.
http://www.prevx.com/ <-->-->
http://info.prevx.com/downloadcsi.asp <-->-->Choice of PCmag editor - Prevx-
http://www.PCMag.com/Article2/0, 2817,2346862,00.aspTry the demo version of Hitman Pro:
Hitman Pro is a second scanner reviews, designed to save your computer from malicious software (viruses,
Trojan horses, rootkits, etc.). that has infected your computer despite all security measures that you have
taken (such as the anti-virus software, firewall, etc.).
http://www.SurfRight.nl/en/hitmanpro--------------------------------------------------------
If necessary here are some free online scanners to help the
http://www.eset.com/onlinescan/
http://OneCare.live.com/site/en-us/default.htm
http://www.Kaspersky.com/virusscanner
Other tests free online
http://www.Google.com/search?hl=en&source=HP&q=antivirus+free+online+scan&AQ=f&OQ=&AQI=G1--------------------------------------------------------
Also do to the General corruption of cleaning and repair/replace damaged/missing system files.
Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup
Start - type this in the search box-> find COMMAND at the top and RIGHT CLICK – RUN AS ADMIN
Enter this at the command prompt - sfc/scannow
How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe)
program generates in Windows Vista cbs.log
http://support.Microsoft.com/kb/928228Run checkdisk - schedule it to run at the next startup, then apply OK then restart your way.
How to run the check disk at startup in Vista
http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html-----------------------------------------------------------------------
If we find Rootkits use this thread and other suggestions. (Run UnHackMe)
I hope this helps.
Rob - bicycle - Mark Twain said it is good.
-
Move a node in an XML (Jdev 11.1.1)
Hi all
I'm writing a query to move a node within a XML.
For example, of:
< root >
< fields >
< field id = "1" >... < / field >
< field id = "2" >... < / field >
< field id = "3" >... < / field >
< field id = "4" >... < / field >
* < field id = "5" >... < / field > *.
< / fields >
< / root >
TO:
< root >
< fields >
< field id = "1" >... < / field >
* < field id = "5" >... < / field > *.
< field id = "2" >... < / field >
< field id = "3" >... < / field >
< field id = "4" >... < / field >
< / fields >
< / root >
I can do it in 3 steps:
1 exctractnode +//field[@id="5"]+ for recovery < field id = "5" >... < / field >
2 deleteXML for the +//field[@id="5"]+ node
3 insertXMLBefore +//field[@id="2"]+
Is it possible to do in 1 single step and for several overseas departments? (I need to do it in java)
Thank you
Cristian
Published by: on February 3, 2011 baol 5.53And wouldn't be a real UPDATE on XMLTYPE fileld XML on my Document table.
Then do a UPDATE :)
SQL> create table document ( 2 doc_id number, 3 xml xmltype 4 ); Table created SQL> insert into document values(1, 2 xmltype('
3 ') 11 ); 1 row inserted SQL> update document d 2 set d.xml = 3 insertXMLBefore( 4 deleteXML( 5 d.xml, 6 '//field[@id="5"]' 7 ), 8 '//field[@id="2"]', 9 XMLQuery('$d//field[@id="5"]' passing d.xml as "d" returning content) 10 ) 11 where d.doc_id = 1 12 ; 1 row updated SQL> set long 10000 SQL> select xmlserialize(document xml as clob indent) from document; XMLSERIALIZE(DOCUMENTXMLASCLOB --------------------------------------------------------------------------------4 10F1 5F2 6F3 7F4 8F5 9F1 F5 F2 F3 F4 And since you are working with java, do not forget to use bind variables to execute the statement.
Something like (not tested):update document d set d.xml = insertXMLBefore( deleteXML( d.xml, '//field[@id="'|| ? ||'"]' ), '//field[@id="'|| ? ||'"]', XMLQuery('$d//field[@id=$ID]' passing d.xml as "d", ? as "ID" returning content ) ) where d.doc_id = 1 ;
-
My event.result may or may not return a node in the xml file. How can I avoid that TypeError: Error #1009: cannot access a property or method of a null object reference.
I have a very simple question. I want to take the value of
Event.Result.Item.nodeindex1.nodeindex2.Row.MyValue;
and assign it to a text field
mytextTi.text = event.result.item.nodeindex1.nodeindex2.row.myvalue;
But if a part of the tree is missing, which is also valid, so I get TypeError: Error #1009: cannot access a property or method of a null object reference.
I tried various solutions such as the following. Is there any simple way to do this?
If (event.result.item.nodeindex1.nodeindex2.row.myvalue! = undefined)-does not work
Unfortunately, one must test all levels to ensure that it is not null before the reference to it. You can take advantage of the short-circuit evaluation in tying together, for example
if (event.result.item && event.result.item.nodeindex1 && event.result.item.nodeindex1.nodeindex2 && event.result.item.nodeindex1.nodeindex2.row && event.result.item.nodeindex1.nodeindex2.row.myvalue) { // access the variable } else { // one of the XML nodes in the path is null }
Or you could stay away from her a little hacky and wrap the reference in a try/catch block.
-Tom
Flex SDK engineer
-
Change "current node" of the XML object
Hello
I am trying to edit the "current node" of an XML object, but I still don't know what will be the current node.
My XML object to load an external XML file:
< mx:XML id = source="assets/article_text.xml"/ "featureData" >
and I read that data through a < mx:Repeater > create a < mx:TextArea > for each 'currentItem '.
< mx:Repeater id = dataProvider = "{featureData.body_text.children ('repeatParas')}" >
"< mx:TextArea htmlText =" {repeatParas.currentItem} "width ="80% "borderStyle ="none"click =" showBodyEditor (event, event.currentTarget.getRepeaterItem ()) "verticalScrollPolicy =" off "creationComplete ="resizeTextArea (event); "updateComplete ="resizeTextArea (event); "/ > < / mx:Repeater >
A click on < mx:TextArea > event load a pop-up window containing a RichTextEditor that contains the content of currentItem:
private void showBodyEditor(event:Event,_item:String):void {}
var pop1:BodyEditor = BodyEditor (PopUpManager.createPopUp (this, BodyEditor, true));
Set the properties of the custom component BodyEditor.
POP1.showCloseButton = true;
POP1.targetBodyText = event.currentTarget;
POP1. CurrentNode = item;
PopUpManager.centerPopUp (pop1);
}
I then passes the value of everything that has been entered in the return to the initial < mx:TextArea > RichTextEdior via a function on a button click event '' made '' (processBodyText()):
[Bindable]
public var targetBodyText:Object;
[Bindable]
public var currentNode:String;
Transfer data to text boxes
private function processBodyText (): void {}
targetBodyText.htmlText = String (bodyTextForm.htmlText);
currentNode = String (bodyTextForm.htmlText);
Remove pop-up.
PopUpManager.removePopUp (this);
}
But what I can't do is actually updated for that node in the featureData XML object without explicitly saying what node to update (for example, it works: parentApplication.featureData.body_text.p [1] = String (bodyTextForm.htmlText);) I don't necessarily know which node to update, I just want to be able to update some node I happen to be editing at the time.
Is this possible?
Thanks to anyone who can enlighten us!I'll reply to my own post (where everyone was watching).
I just changed the parameters/variables currentNode type Object (instead of string) and within the processBodyText function, I replaced
currentNode = String (bodyTextForm.htmlText);
with
currentNode.setChildren (bodyTextForm.htmlText);
who updates the node in the XML data provider.
I still need to get rid of some of the gobblygook of html that is passed to the rear (for example < TEXTFORMAT LEADING '2' = >) but as long as I am able to update the current node, I'm happy (for now).
-
restrict the application of hierarchy based on a given value at the leaf node level
Is it possible to restrict a query of the hierarchy based on a test given at the leaf node level?
For example, in the data presented below, I like to shoot the entire hierarchy for terminal nodes that have 'John' in the criteria:
Parent value criteria
Z
A Z
B HAS
C B John
D B Smith
E Z
F E
John F G
H F Neal
I have F John
Filertering on John I want to return together to resemble the following prints:
A
B
C
F
G
I have
I tried the following, but it only gives me the nodes:
SELECT
LPAD (' ', (LEVEL) * 3,'.) ') || t.Valeur
OF tbl_test t
WHERE t.criteria = "John".
START WITH t.valeur = "Z".
CONNECT BY PRIOR t.valeur = t.parent;
Rule return form the above query:
C
G
I have
Any help is greatly appreciated.It is possible, but not conventional =)
Sys_connect_by_path allows you to concatenate the path and another request of the hierarchy of dividing a value generated in the rows.
with t as ( select 'Z' as Val , null as Par, null as Criteria from dual union all select 'A' as Val , 'Z' as Par, null as Criteria from dual union all select 'B' as Val , 'A' as Par, null as Criteria from dual union all select 'C' as Val , 'B' as Par, 'John' as Criteria from dual union all select 'D' as Val , 'B' as Par, 'Smith' as Criteria from dual union all select 'E' as Val , 'Z' as Par, null as Criteria from dual union all select 'F' as Val , 'E' as Par, null as Criteria from dual union all select 'G' as Val , 'F' as Par, 'John' as Criteria from dual union all select 'H' as Val , 'F' as Par, 'Neal' as Criteria from dual union all select 'I' as Val , 'F' as Par, 'John' as Criteria from dual ) select distinct regexp_substr(path, '[^,]+', 1, level) as val from ( SELECT sys_connect_by_path(val,',') as path , rownum as row_id FROM t WHERE t.criteria = 'John' START WITH t.val = 'Z' CONNECT BY t.par = PRIOR t.val ) connect by nocycle regexp_substr(path, '[^,]+', 1, level) is not null and prior row_id= row_id and prior dbms_random.value is not null
-
I was ruining my brain on this and I am sure that it is possible that I am not sure what is the appropriate search expression.
If I have an XML document, like this:
elements <>
< item >
foo < linkurl > < / linkurl >
< item >
< linkurl > bar < / linkurl >
< / point >
< / point >
< / object >
Lets say, I am looking for the parent of the item element that has an element linkurl with value 'bar' I expect to write something like this:
< cfset itemArray = xmlSearch (xmlDoc, "ancestor: / / item [linkurl = 'bar']") >
I know that for this case specific I could access it directly, but in my case, it can be a lot < element > tags nested so I want it to be dynamic, so that I can continue to walk up the tree.
Any help will be appreciatedThis has been posted a few times because of a bad internet connection, in any case with my XPath Explorer plugin faithful, I was able to get the solution:
If you started playing with XML and XPath in particular and you use Eclipse plugin XPath Explorer is invaluable!
-
ORA-19030: invalid method for the schema not based XML Documents
Hi everyone can u help me please when I am trying to execute query below his throw errror
DECLARE
doc xmltype.
BEGIN
SELECT
XMLAGG (XMLElement ("employee",
XMLAttributes)
' http://www.Oracle.com/emp_simple.xsd ' AS 'xmlns',
' http://www.w3.org/2001/XMLSchema-instance ' AS ' xmlns: xsi ",
' http://www.Oracle.com/emp_simple.xsd
http://www.oracle.com/emp_simple.xsd'
AS "xsi: schemaLocation").
XMLForest (e.employee_id LIKE "EmployeeId",
Select AS "name."
e.job_id AS "Job."
e.manager_id "MANAGER."
e.hire_date AS "Hire Date"
e.Salary AS "wages."
e.commission_pct AS 'The Commission',
XMLForest)
d.department_id AS "DeptNo."
d.department_name AS "DeptName",.
d.location_id AS 'Place') AS 'Dept')))
in the doc
E employees, departments d
WHERE e.department_id = d.department_id;
doc.schemaValidate ();
END;
/
The error I get is following
ORA-19030: invalid method for the schema not based XML Documents
Yes, Odie meant something like that.
See how the employee node can now occur more than once in the employees node.
-
Schema validation fails on the transformed XML document
OK, this is weird.
I get XML files that are supposed to conform to a given XSD. There are dozens of different parties who send these files. To be more precise, I refer to the Ontario Energy Board (OEB) PIPE Documents.
I found that at least one sender sends invalid files. I can't that fixes to the source, so I'm working around that.
for example
Oracle is not like this:<?xml version="1.0" encoding="UTF-8"?> <PIPEDocument xmlns="http://www.oeb.gov.on.ca" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.oeb.gov.on.ca/ PIPEDocument.xsd" Version="4.0" DocumentReferenceNumber="xxx" CreationDate="20110825100008000ES"> <MarketParticipantDirectory> <Sender> ...
OK, so to work around this problem, before schema validation, I apply an XSLT transformation to clean the top-level element:ORA-31154: invalid XML document ORA-19202: Error occurred in XML processing LSX-00344: namespace values "http://www.oeb.gov.on.ca" and "http://www.oeb.gov.on.ca/" differ
Nice: the fact that it is intended for:<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.oeb.gov.on.ca"> <xsl:output method="xml" indent="no"/> <xsl:template match="/"> <xsl:copy> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:if test="local-name() = name()"> <xsl:element name="{local-name()}"> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:if> </xsl:template> <xsl:template match="@*"> <xsl:if test="local-name() = name()"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="."/> </xsl:attribute> </xsl:if> </xsl:template> </xsl:stylesheet>
If I now the schema validate the above transformed XML, then it validates OK.<?xml version="1.0" encoding="UTF-8"?> <PIPEDocument xmlns="http://www.oeb.gov.on.ca" Version="4.0" DocumentReferenceNumber="50520110825080908VA0001.EBT" CreationDate="20110825100008000ES"> <MarketParticipantDirectory> <Sender> ...
Large? No, if I try to turn on the fly (i.e. without first transformation and followed by reading in the transformed data from the file), I get a strange error:
declare v_xml xmltype := xmltype(bfilename('ERS_FILE_LOAD_308', 'DecryptedFile-30873604.xml'), 0).transform(XDBURIType('/ERS_TEST01/PIPE/XSLT/V1.0/pre_validate_XSLT.xsl').getXML()); v_xsd_name varchar2(255) := 'PIPE/Power/V4.0/PIPEDocument.xsd'; begin if v_xml.isSchemaValid(v_xsd_name) = 1 then dbms_Output.put_line('valid'); else dbms_Output.put_line('invalid'); --in order to get specific error info for a non-schema message need to convert the XML to schema based v_xml := v_xml.createSchemaBasedXML(v_xsd_name); v_xml.schemaValidate(); end if; end; /
Exsqueeze me? What element in the schema?ORA-31043: Element '' not globally defined in schema ''
The transformation itself works very well. Specifically, if I run the following:
... I get the desired result. Of course, if I save the result file and validate the fact that it works:select xmltype(bfilename('ERS_FILE_LOAD_308', 'DecryptedFile-30873604.xml'), 0).transform(XDBURIType('/ERS_TEST01/PIPE/XSLT/V1.0/pre_validate_XSLT.xsl').getXML()).getclobval() from dual;
I would like to join example XML file, but it contains customer data so I can't do that. I would fix the XSD but it is the nest of a rat of 50 XSD with includes and a 300 script online registration scheme, so I can't do that.declare v_xml xmltype := xmltype(bfilename('ERS_FILE_LOAD_308', 'DecryptedFile-30873604_manually_saved.xml'), 0); v_xsd_name varchar2(255) := 'PIPE/Power/V4.0/PIPEDocument.xsd'; begin if v_xml.isSchemaValid(v_xsd_name) = 1 then dbms_Output.put_line('valid'); else dbms_Output.put_line('invalid'); --in order to get specific error info for a non-schema message need to convert the XML to schema based v_xml := v_xml.createSchemaBasedXML(v_xsd_name); v_xml.schemaValidate(); end if; end; /
What I'm missing here?
Looks like an Oracle bug for me at this isSchemaValid binds to a beginning of the XML instance and not to the instance transformed.
thoughts?
(using database Oracle 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production under linux)
Published by: Pollocks01 on October 18, 2011 16:11Hello
Looks like an Oracle bug for me at this isSchemaValid binds to a beginning of the XML instance and not to the instance transformed.
That wouldn't be surprising. There are "few" bugs on the XSL transformation.
Here's a recently posted: {: identifier of the thread = 2245703}The solution was to serialize the output and analyze again.
So, what you describe on 'reading of a works file' makes me think it's the same kind of problem.You can also view the contents of the variable just after that:
v_xml := v_xml.createSchemaBasedXML(v_xsd_name);
?
-
What is the best way to apply choice relational tables in the XML document?
I've got an XML document from outside I turn with full DB XSLT document.
Some parts of the document contain codes I want to tranfsorm to significant labels of relational tables in our database.
On road is to disassemble the XML into the relational views and join these views with tables of choice and then back, this time with labels translated, using XMLElement, etc...
Is there another way less heavy? For example,.
Select updateXML)
xml_dta
,'/ / section_to_translate/node_to_translate/variable / text () '
,(
Select the label
of table_recherche
where Group = extractValue (current_node, '... / Group/Text () ')
and code = extractValue (current_node, '... / variable/Text () ')
)
) xml_dta
from my_table
where... criteria
However, I do not know how to move from the current node to the extractValue function (if it is possible?.)
Anyone done the second way?
Thank youYou didn't tell the version of your database, so I assume one of them later.
You can include the part of the translation in the XSL transformation, by accessing an external research paper generated from the database beforehand.
Here is an example of use of the HR diagram example:
(1) the source document that are to be processed: emp.xml
198 Donald OConnell SH_CLERK 199 Douglas Grant SH_CLERK 200 Jennifer Whalen AD_ASST 201 Michael Hartstein MK_MAN 202 Pat Fay MK_REP 203 Susan Mavris HR_REP 204 Hermann Baer PR_REP 205 Shelley Higgins AC_MGR 206 William Gietz AC_ACCOUNT 100 Steven King AD_PRES (2) the lookup table:
SQL> create table lookup_table as 2 select job_id, job_title 3 from hr.jobs; Table created SQL> select * from lookup_table; JOB_ID JOB_TITLE ---------- ----------------------------------- AD_PRES President AD_VP Administration Vice President AD_ASST Administration Assistant FI_MGR Finance Manager FI_ACCOUNT Accountant AC_MGR Accounting Manager AC_ACCOUNT Public Accountant SA_MAN Sales Manager SA_REP Sales Representative PU_MAN Purchasing Manager PU_CLERK Purchasing Clerk ST_MAN Stock Manager ST_CLERK Stock Clerk SH_CLERK Shipping Clerk IT_PROG Programmer MK_MAN Marketing Manager MK_REP Marketing Representative HR_REP Human Resources Representative PR_REP Public Relations Representative 19 rows selected
(3) generate us the document search and store it in the XML DB repository (so that it can be referenced in the XSLT):
SQL> show user User is "dev" SQL> SQL> declare 2 res boolean; 3 begin 4 res := dbms_xdb.CreateResource( 5 abspath => '/public/temp/lookup.xml', 6 data => dburitype('/DEV/LOOKUP_TABLE').getXML 7 ); 8 commit; 9 end; 10 / PL/SQL procedure successfully completed SQL> set long 10000 SQL> select xdburitype('/public/temp/lookup.xml').getCLOB() from dual; XDBURITYPE('/PUBLIC/TEMP/LOOKU --------------------------------------------------------------------------------
AD_PRES President AD_VP Administration Vice President AD_ASST Administration Assistant FI_MGR Finance Manager FI_ACCOUNT Accountant AC_MGR Accounting Manager AC_ACCOUNT Public Accountant SA_MAN Sales Manager SA_REP Sales Representative PU_MAN Purchasing Manager PU_CLERK Purchasing Clerk ST_MAN Stock Manager ST_CLERK Stock Clerk SH_CLERK Shipping Clerk IT_PROG Programmer MK_MAN Marketing Manager MK_REP Marketing Representative HR_REP Human Resources Representative PR_REP Public Relations Representative (4) the sheet XSLT stylesheet (stored in XDB repository as well): emp.xsl
The transformation is rather bland, but the interesting part lies in access to external document within it.
I used a key to index the JOB_ID/function pairs.(5) last step, apply the transformation:
SQL> select xmlserialize(document 2 xmltransform( 3 xmltype(bfilename('DUMP_DIR','emp.xml'),nls_charset_id('AL32UTF8')), 4 xdburitype('/public/temp/emp.xsl').getXML() 5 ) as clob indent 6 ) 7 from dual; XMLSERIALIZE(DOCUMENTXMLTRANSF --------------------------------------------------------------------------------
Donald OConnell Shipping Clerk Douglas Grant Shipping Clerk Jennifer Whalen Administration Assistant Michael Hartstein Marketing Manager Pat Fay Marketing Representative Susan Mavris Human Resources Representative Hermann Baer Public Relations Representative Shelley Higgins Accounting Manager William Gietz Public Accountant Steven King President The input document is transformed and each job_id is replaced by its corresponding label.
-
Merge the XML document in a table
Hello
I want to merge some of the values of an xml document in a table "Project_Table".
CREATE TABLE Project_Table
(
TASK_ID NUMBER (15),
TASK_NAME VARCHAR2 (100 BYTE),
START_DATE DATE,
)
I am using the following procedure, that I adapted from another post. It inserts null values, I think because I'm not showing the nodes correctly.
DECLARE
BFILE v_bfile: = BFILENAME ("'DTEMP","test.xml");
v_clob CLOB.
BEGIN
-Create directory DTEMP as "C:\TEMP";
-grant read the < schema > DTEMP directory;
DBMS_LOB.CREATETEMPORARY (v_clob, TRUE);
DBMS_LOB. OPEN (v_bfile, DBMS_LOB.lob_readonly);
DBMS_LOB. LoadFromFile (v_clob, v_bfile, DBMS_LOB.lobmaxsize);
Dbms_output.put_line (v_clob);
MERGE IN project_table t
USING (SELECT TO_NUMBER (EXTRACTVALUE (VALUE (x), ' / task ')) task_id,)
To_date (EXTRACTVALUE (value (x), "/ start"), 'DD-MM-YYYY') start_date,
EXTRACTVALUE (value (x), "/ name") TaskName
(SELECT XMLTYPE (v_clob) XML
THE DOUBLE).
TABLE (XMLSEQUENCE (EXTRACT (xml, ' / project'))) x) r
WE (t.task_id = r.task_id)
WHEN MATCHED THEN
UPDATE
SET t.start_date = r.start_date, t.task_name = r.task_name
WHEN NOT MATCHED THEN
INSERT (task_id, start_date, taskname)
VALUES (r.task_id, r.start_date, r.task_name);
COMMIT;
END;
This is the document of test.xml.
<? XML version = "1.0" encoding = "UTF-8"? >
-name of the project 'ProjectName' company 'Company' webLink = = = "" view-date = '2009-12-14"see-index '0' = gantt-Divider-location = '300' resource-divider-card ="300"version ="2.0">"
< description / >
< zoom-view state = "default: 8" / >
-<!
->
-< calendars >
-day-types >
< day-type id = '0' / >
< day-type id = "1" / >
-< Calendar id = "1" name = "default" >
< Sun weeks default = '0' LUN '0' = TEU = '0' kills = '0' game = '0' Fri '0' = Saturday = '0' / >
< overloaded-day-types / >
< days / >
< / calendar >
< / day-types >
< / calendars >
-task color = "#8cb6ce" >
-< taskproperties >
< taskproperty id = "tpd0" name = 'type' type = 'default' valuetype = "icon" / >
< taskproperty id = "TDP1" name = 'priority' type = 'default' valuetype = "icon" / >
< taskproperty id = "tpd2" name = 'info' type = 'default' valuetype = "icon" / >
< taskproperty id = "tpd3" name = "name" type = 'default' valuetype = "text" / >
< taskproperty id = "tpd4" name = "begindate" type = 'default' valuetype = "date" / >
< taskproperty id = "tpd5" name = "enddate" type = 'default' valuetype = "date" / >
< taskproperty id = "tpd6" name = "Duration" type = 'default' valuetype = "int" / >
< taskproperty id = "tpd7" name = "completion" type = 'default' valuetype = "int" / >
< taskproperty id = "tpd8" name = "Coordinator" type = 'default' valuetype = "text" / >
< taskproperty id = "tpd9" name = "predecessorsr" type = "default" valuetype = "text" / >
< / taskproperties >
< job id = '0' name = 'TaskA"color =" #0099cc "form = meeting"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"="false"start ="2010-01-28"duration ="1"complete ="0"priority ="1"expand ="true"/ >
< task id = "1" name = "TaskB" color = "#ff0000" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-01-28" duration = "1" complete = "100" priority = "1" expand = "true" / >
< job id = "2" name = 'Day' color = "#ff9933" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-02-01" duration = "19" complete = "0" priority = "1" expand = "true" / >
< job id = "3" name = "TaskD" color = "#ff0000" form = "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" meeting = "false" start = "2010-02-01" duration = "32" full = "100" priority = "1" expand = "true" / >
< job id = "4" name = "TaskE" color = "#66ff99" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-02-01" duration = "67" complete = "0" priority = "1" expand = "true" / >
< job id = "5" name = "TaskF" color = "#66ff99" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-02-01" duration = "46" complete = "10" priority = "1" expand = "true" / >
< job id = "6" name = "TaskG" color = "#00cccc" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-03-15" duration = "30" complete = "0" priority = "1" expand = "true" / >
< job id = "7" name = "TaskH" color = "#00cccc" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = "2010-03-15" duration = "103" full '1' = '1' priority = expand = "true" / >
< job id = "8" name = "TaskI" color = "#0000ff" form = meeting "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" = "false" start = '2010-04-26' length = "11" complete = "0" priority = "1" expand = "true" / >
< job id = '9' name = 'TaskJ"color =" #0000ff "form = meeting"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"="false"start = '2010-04-26' length ="11"complete ="0"priority ="1"expand ="true"/ >
< job id = "10" name = "TaskK" color = "#000000" meeting = 'false' start time = "2010-07-12" = "65" full = "0" priority = "1" expand = "true" / >
< / tasks >
< resources / >
< allowances / >
< holiday / >
-< taskdisplaycolumns >
< displaycolumn property id = "tpd3" order = "0" width = "75" / >
< displaycolumn property id = "tpd4" order = "1" width = "75" / >
< displaycolumn property id = "tpd5" order = "2" width = "75" / >
< displaycolumn property id = "tpd7" order = "3" width = "75" / >
< / taskdisplaycolumns >
< Previous / >
< roles roles-name = "Default" / >
< / project >
Any ideas how to change the procedure, in order to merge the data in the xml document in the table?
Thank youHello
Here's what you need in your USING clause:
SELECT to_number(extractvalue(column_value, 'task/@id')) as task_id, to_date(extractvalue(column_value, 'task/@start'), 'YYYY-MM-DD') as start_date, extractvalue(column_value, 'task/@name') as task_name FROM TABLE( XMLSEQUENCE( EXTRACT(xmltype(v_clob), '//task') ) )
Since you want nodes "task" request, just extract them directly. In addition, 'id', 'start', 'name' is attributes, you must access them with an '@'.
You can also take a look at function XMLTABLE (which tends to replace construction TABLE (XMLSEQUENCE (...))):
SELECT * FROM XMLTABLE( '//task' passing xmltype(v_clob) columns task_id number(15) path '/task/@id', start_date date path '/task/@start', task_name varchar2(100) path '/task/@name' )
Edit: the XMLType constructor overload taking a BFILE type as an argument, so you can simplify the code a bit more:
DECLARE v_xml XMLTYPE := XMLTYPE( BFILENAME('DTEMP', 'test.xml'), nls_charset_id('AL32UTF8') ); BEGIN MERGE INTO project_table t USING ( SELECT * FROM XMLTABLE( '//task' passing v_xml columns task_id number(15) path '/task/@id', start_date date path '/task/@start', task_name varchar2(100) path '/task/@name' ) ) r ON (t.task_id = r.task_id) WHEN MATCHED THEN ... WHEN NOT MATCHED THEN ... ; ... END;
HTH
Published by: odie_63 on March 18, 2010 12:13
Published by: odie_63 on March 18, 2010 12:15
Maybe you are looking for
-
Pixellisant when you press the screen - MBP w / retina
Then... I'm a bit overprotective of my stuff from Apple - start w / that. I accidentally pushed my thumb up against the screen and there were some comments/pixellisant (don't know how to call it) which disappeared when I took my thumb off the screen.
-
Not in computer science. Don't know how to use foxfire. Very used to the mini opera a bit confused with foxfire. Tried to use Google account they directed me to download new opera browser said was outdated. Cannot get my password to work on Google. I
-
Windows Updater gives me an error; 80072efb
My computer has been out of service for about a year. It was last updated was Feb. in 2009. I loaned my boyfriend for his bankruptcy and now its not updated. Comes up with the error; 80072efb. He tried using the command prompt with the code; netsh wi
-
Print anywhere without hp e-print E-Mail?
Hi, I have a HP Deskjet 3520. I wonder if it is possible to print anywhere (out of reach of the local network) without sending it to the email address (... @hpeprint.com)? For example, if I try to print a Web page on the go. Is it possible to send th
-
Air or webworks, need advice
Hello everyone. I began my foray into php and am not sure of what the platform to use and hope that someone can give me a little advice. I am building a mapping with the api of Google Maps application. I have a Web host running configuration / php, a