XQuery many to one in an XML document ??
I have XMLType tables with xml documents that have data like the sample below.
There are one to many InvoiceLineRet to one InvoiceRet, how do I return this data in an XQuery?
I have tried many iterations but cannot get data to return correctly. It is somewhat like a many to one table relation where in the query the one side would repeat across the many lines, but it does not work that way with XQuery.
Any and all suggestions will be appreciated.
Thanks,
Mike
sample data:
<InvoiceRet>
<TxnID>D924-1210085400</TxnID>
<TimeCreated>2008-05-06T10:50:00-05:00</TimeCreated>
<TimeModified>2008-07-21T10:54:42-05:00</TimeModified>
<EditSequence>1215638595</EditSequence>
<TxnNumber>10398</TxnNumber>
<CustomerRef>
<ListID>80000278-1209483158</ListID>
<FullName>Majestic Entries</FullName>
</CustomerRef>
<ARAccountRef>
<ListID>80000009-1185470478</ListID>
<FullName>Accounts Receivable</FullName>
</ARAccountRef>
<TemplateRef>
<ListID>80000019-1190228214</ListID>
<FullName>Compudoc</FullName>
</TemplateRef>
<TxnDate>2008-05-06</TxnDate>
<RefNumber>22333</RefNumber>
<BillAddress>
<Addr1>Majetic Entries</Addr1>
</BillAddress>
<BillAddressBlock>
<Addr1>Majetic Entries</Addr1>
</BillAddressBlock>
<IsPending>false</IsPending>
<IsFinanceCharge>false</IsFinanceCharge>
<DueDate>2008-05-06</DueDate>
<ShipDate>2008-05-06</ShipDate>
<Subtotal>391.50</Subtotal>
<ItemSalesTaxRef>
<ListID>8000004F-1185996977</ListID>
<FullName>NC 7.25%</FullName>
</ItemSalesTaxRef>
<SalesTaxPercentage>7.25</SalesTaxPercentage>
<SalesTaxTotal>5.73</SalesTaxTotal>
<AppliedAmount>-397.23</AppliedAmount>
<BalanceRemaining>0.00</BalanceRemaining>
<IsPaid>true</IsPaid>
<IsToBePrinted>false</IsToBePrinted>
<IsToBeEmailed>false</IsToBeEmailed>
<CustomerSalesTaxCodeRef>
<ListID>80000001-1185469345</ListID>
<FullName>Tax</FullName>
</CustomerSalesTaxCodeRef>
<InvoiceLineRet>
<TxnLineID>D926-1210085400</TxnLineID>
<ItemRef>
<ListID>80000059-1199714336</ListID>
<FullName>Labor:Non-Contract Labor Ken</FullName>
</ItemRef>
<Desc>Technical Labor performed by Ken Allen:
Network Problem with Internet and intranet found two routers connected together and the one set for DHCP was bad we changed out their bad one with our small netgear router.</Desc>
<Quantity>1.5</Quantity>
<Rate>125.00</Rate>
<ClassRef>
<ListID>8000000D-1200208143</ListID>
<FullName>KA</FullName>
</ClassRef>
<Amount>187.50</Amount>
<ServiceDate>2008-04-28</ServiceDate>
<SalesTaxCodeRef>
<ListID>80000002-1185469345</ListID>
<FullName>Non</FullName>
</SalesTaxCodeRef>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>D927-1210085400</TxnLineID>
<ItemRef>
<ListID>80000029-1185470511</ListID>
<FullName>Labor:Non-Contract Labor Rick</FullName>
</ItemRef>
<Desc>Technical Labor performed by Rick Wagoner: Assisted with above troubleshooting</Desc>
<Quantity>1</Quantity>
<Rate>125.00</Rate>
<ClassRef>
<ListID>80000004-1185998300</ListID>
<FullName>RW</FullName>
</ClassRef>
<Amount>125.00</Amount>
<ServiceDate>2008-04-28</ServiceDate>
<SalesTaxCodeRef>
<ListID>80000002-1185469345</ListID>
<FullName>Non</FullName>
</SalesTaxCodeRef>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>D928-1210085400</TxnLineID>
<ItemRef>
<ListID>80000050-1185997340</ListID>
<FullName>Parts and Supplies</FullName>
</ItemRef>
<Desc>Parts and Supplies: Netgear router</Desc>
<Quantity>1</Quantity>
<Rate>79.00</Rate>
<ClassRef>
<ListID>80000007-1186694551</ListID>
<FullName>Parts</FullName>
</ClassRef>
<Amount>79.00</Amount>
<SalesTaxCodeRef>
<ListID>80000001-1185469345</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
</InvoiceLineRet>
</InvoiceRet>
<InvoiceRet>
<TxnID>ED59-1216758177</TxnID>
<TimeCreated>2008-07-22T16:22:57-05:00</TimeCreated>
<TimeModified>2008-07-26T11:21:48-05:00</TimeModified>
<EditSequence>1217085708</EditSequence>
<TxnNumber>11203</TxnNumber>
<CustomerRef>
<ListID>80000278-1209483158</ListID>
<FullName>Majestic Entries</FullName>
</CustomerRef>
<ARAccountRef>
<ListID>80000009-1185470478</ListID>
<FullName>Accounts Receivable</FullName>
</ARAccountRef>
<TemplateRef>
<ListID>80000019-1190228214</ListID>
<FullName>Compudoc</FullName>
</TemplateRef>
<TxnDate>2008-07-22</TxnDate>
<RefNumber>22479</RefNumber>
<BillAddress>
<Addr1>Majetic Entries</Addr1>
</BillAddress>
<BillAddressBlock>
<Addr1>Majetic Entries</Addr1>
</BillAddressBlock>
<IsPending>false</IsPending>
<IsFinanceCharge>false</IsFinanceCharge>
<DueDate>2008-07-22</DueDate>
<ShipDate>2008-07-22</ShipDate>
<Subtotal>839.00</Subtotal>
<ItemSalesTaxRef>
<ListID>8000004F-1185996977</ListID>
<FullName>NC 7.25%</FullName>
</ItemSalesTaxRef>
<SalesTaxPercentage>7.25</SalesTaxPercentage>
<SalesTaxTotal>33.64</SalesTaxTotal>
<AppliedAmount>0.00</AppliedAmount>
<BalanceRemaining>872.64</BalanceRemaining>
<IsPaid>false</IsPaid>
<IsToBePrinted>true</IsToBePrinted>
<IsToBeEmailed>false</IsToBeEmailed>
<CustomerSalesTaxCodeRef>
<ListID>80000001-1185469345</ListID>
<FullName>Tax</FullName>
</CustomerSalesTaxCodeRef>
<InvoiceLineRet>
<TxnLineID>ED5B-1216758177</TxnLineID>
<ItemRef>
<ListID>80000050-1185997340</ListID>
<FullName>Parts and Supplies</FullName>
</ItemRef>
<Desc>Parts and Supplies - Linksys Router</Desc>
<Quantity>1</Quantity>
<Rate>89.00</Rate>
<Amount>89.00</Amount>
<SalesTaxCodeRef>
<ListID>80000001-1185469345</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED5C-1216758177</TxnLineID>
<Desc>Suspect that the phone switch is attempting to act as a DHCP server for the network. per Terry, the reason that the phone switch was on the network was to supply VOIP to the warehouse phone lines. This was not working and is no longer needed. We removed the connection between the phone switch and the network.</Desc>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED5D-1216758177</TxnLineID>
<Desc>Removed the Netgear router and the D-Link router. The D-Link had lost all settings and we could not log into the Netgear even after resetting to factory defaults.</Desc>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED5E-1216758177</TxnLineID>
<Desc>Installed a new Lnksys router to replace the D-Link and Netgear faulty routers.</Desc>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED5F-1216758177</TxnLineID>
<Desc>Ensured that all computers were connecting properly. Ensured that all computers printed to the Savin printer correctly.</Desc>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED60-1216758177</TxnLineID>
<Desc>Worked with Time Warner Cable to resolve customer location and static IP.</Desc>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED64-1216758177</TxnLineID>
<ItemRef>
<ListID>80000028-1185470511</ListID>
<FullName>Labor:Non-Contract Labor Kareem</FullName>
</ItemRef>
<Desc>Analyzed and resolved Internet connectivity problems after loss of service from Time Warner Cable.</Desc>
<Quantity>3</Quantity>
<Rate>125.00</Rate>
<Amount>375.00</Amount>
<ServiceDate>2008-07-22</ServiceDate>
<SalesTaxCodeRef>
<ListID>80000002-1185469345</ListID>
<FullName>Non</FullName>
</SalesTaxCodeRef>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED68-1216758177</TxnLineID>
<ItemRef>
<ListID>8000005D-1216758445</ListID>
<FullName>Labor:Non-Contract Labor Mike</FullName>
</ItemRef>
<Desc>Analyzed and resolved Internet connectivity problems after loss of service from Time Warner Cable.</Desc>
<Quantity>3</Quantity>
<Rate>125.00</Rate>
<Amount>375.00</Amount>
<ServiceDate>2008-07-22</ServiceDate>
<SalesTaxCodeRef>
<ListID>80000001-1185469345</ListID>
<FullName>Tax</FullName>
</SalesTaxCodeRef>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED94-1216758177</TxnLineID>
<Desc>Terry called, cannot connect to internet. Everyone but Terry can connect. Terry is getting a 172 IP address on his laptop. Walked him through putting a static IP on his laptop so that he could be functional. I went to their site and talked with the NEC phone switch management company. They said the switch does not have DHCP capabilities. I could not duplicate Terry's issue using my laptop. The phone switch is now totally disconnected from the network since the VOIP setup for the warehouse was not functional. Validated that the TWC modem is not DHCP.</Desc>
<ServiceDate>2008-07-23</ServiceDate>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>ED95-1216758177</TxnLineID>
<Desc>Requires further diagnostics on Friday the 25th (if Terry is available) - need his laptop on-site to diagnose the problem.</Desc>
</InvoiceLineRet>
<InvoiceLineRet>
<TxnLineID>EE30-1216758177</TxnLineID>
<Desc>Communicated with Terry on 7/24/2008 via email. He is using DHCP and connecting correctly. Removing the final connection from the phone switch to the network appears to have corrected the problem.</Desc>
<ServiceDate>2008-07-24</ServiceDate>
</InvoiceLineRet>
</InvoiceRet>
try to use "xmlTable"
search on this forum u can find much more stuff
Similar Messages
-
InDesign CC crashes when importing XML document
First off thank you for looking and in advance for any help offered. To the issue:
I have an employee that is seeing consistent crashes on In design CC when trying to import one of our XML documents. The XML file is around 150KB so not very big. The actual indesign document and any graphics that might go into it are located on a server that is on our network. The employee is working remotely.
How best to go about troubleshooting this issue?Older scripts may not work directly in CC, but many ought to if placed into subfolders for their versions in your scripts folder, such as "Version 8.0 Scripts" without quotes, but case sensitive, for scripts that run in CS6.
And no, it's not just you having trouble with CC.
Have you seen this: Crash | Launch, selecting Type tool ? -
How to Find Number of Given Element in a XML Document
Hello Experts,
I want to know the number of given element in a XML document. For example if we have an employees information as a XML document, can we have how many <phone> element in the XML document?
Thanks in advance.
Regards,
JPHello,
Once you've answered all the above.
If you can run xpath that supports functions against the xml, the expression:
count(//phone)Otherwise, without leaving SQL:
select count(*) from
xmltable('//phone' passing
-- Your XML goes here, could be a table column with type XMLTYPE.
xmltype('<person><phone>123-456-7890</phone><phone>098-765-4321</phone></person>')
columns phone varchar2(24 char) path '/phone'
; -
Need to chart attribute value of just one child node of XML document
I have a XML document with (for example) 7 parent nodes, each
parent node has 5 child nodes. The parent nodes have an attribute
@EarlierDTS (DateTime type) that is the x-axis category of a chart.
Each child node has an attribute @eventid which specifies the id of
the event, and another atttribute @NumOccurs which specifies how
many times that event occured in that period.
How do I tell Flex I want a simple line chart of the eventID
= 215? What if I want two lines, for both eventID=215 and
eventid=307?
I have studied the posts and blogs for over a week now, and
have seen this question or similar come up quite a few places, with
no answer.
1) Should I focus on learning how to create a filterfunction
for the XMLList that underlies my XMLListCollection so that the
filtered data view is just one child node per parent node ( or two
child nodes for the second case)? And set the filtered data view as
the dataprovider of my chart's vertical series?
2) Should I focus on learning how to create a XML Filter
query that selects just one or two child nodes for each parent
node, and set the charts' series' dataprovider to this filter
expression? (I don't think this is allowed - but I'm checking with
the forum members...)
3) Should I focus on learning how to convert the
XMLListCollection into a HierarchicalData object, and then learning
how to filter this object so there is only one (or two) childs per
parent? This seems like a lot of coding - I almost have to create a
pair of classes - one for the parent and one for the child - so I
can create nested ArrayObjects.
4) Should I create a brand new XMLList by walking the
original XML list, and inserting Parent nodes and just the child
nodes that match the eventID(s) I want to chart, into the new
XMLList?
I believe that the easiest way would be to create a
Filterfunction for the XMLList, and bind the chart series to the
(filtered) XML List. But the problem with this approach is that I
have seen more than 2 posts asking how to accomplish filtering that
removes specific children from the view, with no solutions posted.
Help! What is the best way to get just one child for each
parent, from an XMLList?"whertzing" <[email protected]> wrote in
message
news:[email protected]...
>I have a XML document with (for example) 7 parent nodes,
each parent node
>has 5
> child nodes. The parent nodes have an attribute
@EarlierDTS (DateTime
> type)
> that is the x-axis category of a chart. Each child node
has an attribute
> @eventid which specifies the id of the event, and
another atttribute
> @NumOccurs
> which specifies how many times that event occured in
that period.
>
> How do I tell Flex I want a simple line chart of the
eventID = 215? What
> if I
> want two lines, for both eventID=215 and eventid=307?
>
> I have studied the posts and blogs for over a week now,
and have seen this
> question or similar come up quite a few places, with no
answer.
>
> 1) Should I focus on learning how to create a
filterfunction for the
> XMLList
> that underlies my XMLListCollection so that the filtered
data view is just
> one
> child node per parent node ( or two child nodes for the
second case)? And
> set
> the filtered data view as the dataprovider of my chart's
vertical series?
>
> 2) Should I focus on learning how to create a XML Filter
query that
> selects
> just one or two child nodes for each parent node, and
set the charts'
> series'
> dataprovider to this filter expression? (I don't think
this is allowed -
> but
> I'm checking with the forum members...)
>
> 3) Should I focus on learning how to convert the
XMLListCollection into a
> HierarchicalData object, and then learning how to filter
this object so
> there
> is only one (or two) childs per parent? This seems like
a lot of coding -
> I
> almost have to create a pair of classes - one for the
parent and one for
> the
> child - so I can create nested ArrayObjects.
>
> 4) Should I create a brand new XMLList by walking the
original XML list,
> and
> inserting Parent nodes and just the child nodes that
match the eventID(s)
> I
> want to chart, into the new XMLList?
>
> I believe that the easiest way would be to create a
Filterfunction for the
> XMLList, and bind the chart series to the (filtered) XML
List. But the
> problem
> with this approach is that I have seen more than 2 posts
asking how to
> accomplish filtering that removes specific children from
the view, with no
> solutions posted.
>
> Help! What is the best way to get just one child for
each parent, from an
> XMLList?
I'd just look at a dataFunction. There's an example here that
may point you
in the right direction:
http://flexdiary.blogspot.com/2008/08/charting-example.html
HTH;
Amy -
Only one top level element is allowed in an XML document. Line 2, Position 2
I get this error when I try to run an xsql query with a where clause:
Only one top level element is allowed in an XML document. Line 2, Position 2
<font size='-1' face='monospace'>XSQL-005: XSQL page is not well-formed.</font><BR>
-^
Here is the xsql query I tried to use.
<?xml version="1.0"?>
<xsql:query connection="xmlbook" xmlns:xsql="urn:oracle-xsql">
select * from companytable where companynumber < 1000;
</xsql:query>
nullYou need to escape certain characters in order to make XML documents well formed. The problem in this case is the less than sign between companynumber and 1000. You should replace it with <
I recommend reading a good XML book - "Building Oracle XML Applications" by Steve Muench, for instance.
Brian -
Multiple XML documents in one SWF
Hi, i'm trying to create a mix and match clothing application
using flash for a school project but am having trouble with xml
documents. Using an online tutorial, i found it was quite easy to
load up one xml document, example of code below.
I thought it would be as simple as copying all the code and
changing the variable names to load a second xml document but i
find when i run the code, that only the last xml document in the
code loads, could anyone give me any tips? Thanks
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image
= xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
description
= xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
firstImage();
} else {
content = "file not loaded!";
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");Hi, i checked my text and description boxes in my document,
and it is in fact loading the separate xml document, the problem
seems to stem from the fact that it is not displaying the xml image
within the movie clip.
I have two separate mc's on the stage, with different
instance names, flash displays the description of each separate xml
document, however, it only shows one of the movie clips images, if
i delete one from the actionscript, it shows the other, so it must
be something to do with them overwriting each other, i used a
trace, so i know the data is in flash for the images which arent
being shown, it just isn't showing for some reason. -
Use 1 stylesheet to translate 2 xml documents(raw data)into one result xml
I have one java application which can generate two xml documents (raw data), now i want to have one result xml which contains contents of these two xml documents(raw data) by using one stylesheet. is it possible?
how to match template in the stylesheet?
how to let the stylesheet know that it should read second raw xml?Yes it is possible.
You didn't say whether you want to do this by invoking the transformation from a Java program, or with a stand-alone transformer, and which one.
I've done an application where I had a main XML file and a secondary XML file. I invoked the transformation from Java, and passed a parameter to the stylesteet. It winds up looking like a variable ($parm for example).
Here is the declaration of the param in the stylesheet.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="list" />Next, I use the document function to read the file and produce a result tree (like a DOM object, in a sense).
<xsl:variable name="phonemes"
select="document($list)" />Then, you can use code like the following to look for content in the secondary file:
<xsl:if test="$phonemes/phonemes/allsounds[phoneme=$sound]" >This was complex, but it works.
Another approach would be to have a small XML file with the names of the
two XML files you want to process. You could do a for-each to process each of the tags in this little file, use the document function to read in the file and copy th eoutput to where you need it.
So, in that case, you would be processsing 3 files rather than 2. If you are invoking from Java, the third file could be coded in a String rather than having to physically write it out.
You've got a few ideas to consider.
Dave Patterson -
Only one top level element is allowed in an XML document. Error message
Hi all, Am receiving above message when trying to view XML data generation. Have found little to no documentation on this particular message and thus far unable to research/guess my way to resolition. Any and all help will greatly appreciated. Thanks in advance for the help, harold
I had been using MC Internet Explorer until this . Have compared this one to functioning XML viewable with MS Internet explorer. Below is code I am using trying to resolve this problem.
<?xml version="1.0"?>
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ecrtas"/>
<tt:template>
<tt:loop ref="ecrtas">
<ImportInstructions>
<ProjectSponsorInstruction>
<Instruction mode="Add">
<SponsorName tt:value-ref="SPONME"/>
<SponsorNumber>
<IdValue name="Sponsor Number"><tt:value ref="SPONSOR"/></IdValue>
</SponsorNumber>
<SponsorType tt:value-ref="SPONTYP"/>
</Instruction>
</ProjectSponsorInstruction>
</ImportInstructions>
</tt:loop>
</tt:template>
</tt:transform>
Thank you again -
How to generate an XML Document from XQuery
The following query returns me the required XML output. However, I need to generate an XML Document out of it. How do I go about generating an XML Doc?.
SELECT XMLQuery('<Data>
{for $tert in ora:view("DATA"),
$tert_audit in ora:view("DATA_AUDIT")
let $tert_cmd_id := $tert/ROW/ID/text(),
$tert_spouse_name := $tert/ROW/SPOUSE_NAME/text(),
$tert_directions := $tert/ROW/DIRECTIONS/text(),
$tert_soil_zone := $tert/ROW/SOIL_ZONE/text(),
$tert_audit_cmd_id := $tert_audit/ROW/ID/text(),
$tert_audit_trans_date := $tert_audit/ROW/TRANSACTION_DATE/text()
where $tert_cmd_id = $tert_audit_cmd_id and
$tert_audit_trans_date >= xs:date(V_Last_Successful_Date)
order by $tert_cmd_id
return
<op>
<op_type>I</op_type>
<ent_id>{$tert_cmd_id}</ent_id>
<source>S</source>
<fg>
<val_flds>
<fld>
<id>spouse_name</id>
<val>{$tert_spouse_name}</val>
</fld>
<fld>
<id>directions</id>
<val>{$tert_directions}</val>
</fld>
<fld>
<id>soil_zone</id>
<val>{$tert_soil_zone}</val>
</fld>
</val_flds>
</fg>
</op>}</Data>' RETURNING CONTENT)
INTO V_Other_Insert
FROM dual;Hi Geoff,
I would like to generate an XML file which contains data as shown below:
<Insert>
<result>
<type>A</type>
<id>1</id>
<date>11/11/2006</date>
<source>Web</source>
</result>
</Insert>
I'm using the below given query for this purpose:
SELECT XMLQuery('<Insert>
{for $c in ora:view("TableA")
let $id := $c/ROW/ID/text(),
$code := $c/ROW/CODE/text(),
$type := $c/ROW/TYPE/text(),
$date := $c/ROW/DATE/text()
return
<result>
<type>{$type }</type>
<id>{$id}</id>
<date>{$date}</date>
<source>S</source>
</result> }</Insert>' RETURNING CONTENT)
INTO V_Insert
FROM dual;
V_Insert stores the required result.
How do I save this result to a XML Document?
Please help. -
How to insert one XML document into another
Hi,
I've been working on a simple CMS.
There is a main template that is just a HTML page. The main template has a few extra 'module' tags that indicates places where individual modules have to be placed.
main template: template.xml
<html>
<body>
<div>
<module id="centre"/>
</div>
</body>
</html>module template: module_centre.xml
<div>
<a>This is a MODULE and it may be much more complex</a>
<div>My application has to detect every 'module' tag from the template.xml and insert there XML content from a proper module template.
The result file has to be generated dynamically on a request. The structures of 'modules' can be only defined in module_*.xml files.
The expected result
<html>
<body>
<div>
<div>
<a>This is a MODULE and it may be much more complex</a>
<div>
</div>
</body>
</html>What's the best practice do solve this case?
PawelI think I've came up with a better solution.
SRC file
<?xml version="1.0" encoding="utf-8"?>
<html>
<head>
<title></title>
<style type="text/css">
div.c4 {background-color:pink;width:400px;height:50px}
div.c3 {background-color:green}
div.c2 {background-color:blue;width:400px;height:299px}
div.c1 {background-color:red}
</style>
</head>
<body>
<module id="XXX"/>
<div id="main" class="c3">
<div id="top" class="c1"><module id="menu_test"/></div>
<div id="bottom" class="c2"><module id="menu_test2"/></div>
</div>
<div id="footer_container" class="c4"> <module id="menu_footer"/></div>
</body>
</html>MODULE src file
<?xml version="1.0" encoding="UTF-8"?>
<div id="admin_panel_module" style="background-color:orange;width:200px;height:50px">
<p>Control Panel TEST</p>
</div> @param source - NODES from MODULE document
*@param target - TEMPLATE document where MODULES are going to be inserted*
@throws Exception
public static void insertModules(Node source, Document target) throws Exception {
Node importedNodes = target.importNode(source, true);
// Use XPath to find all 'module' nodes in ''
XPath xpath = XPathFactory.newInstance().newXPath();
NodeList nodes = (NodeList) xpath.evaluate("//module", target, XPathConstants.NODESET);
// Remove MODULE node and insert there an XML content from MODULE template
for (int idx = 0; idx < nodes.getLength(); idx++) {
Node editedModuleElement = nodes.item(idx);
// parent of module mode
Node parentNode = editedModuleElement.getParentNode();
// replace <module/> node with imported nodes from 'module' XML document
parentNode.replaceChild(importedNodes, editedModuleElement);
// nodes.item(idx).appendChild(node);
importedNodes = target.importNode(source, true);
}Edited by: maestr0 on May 24, 2010 12:44 AM -
Generating an XML Document from an internal table in ABAP
Good day to all of you;
With ABAP, in the R/3 system, I'm trying to figure out a way to accomplish the following:
1) SELECT a set of Purchase Order data into an internal table.
2) Generate an XML document, containing the above data, using a specific schema.
I've been playing around with function module SAP_CONVERT_TO_XML_FORMAT which has the following interface:
CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ''
I_LINE_HEADER = ''
I_FILENAME = v_fname
I_APPL_KEEP = ''
I_XML_DOC_NAME = v_docname
IMPORTING
PE_BIN_FILESIZE = v_byte
TABLES
I_TAB_SAP_DATA = i_SapData
CHANGING
I_TAB_CONVERTED_DATA = i_XMLData
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
I'm uncertain as to whether or not the Export parameter, I_XML_DOC_NAME refers to some schema or definition and therefore have been excluding it. In doing so, the generated XML document seems to use the field name/type information from my itab for the tags.
If this function module requires an XML Document Name, how do I create one and where do I store it in R/3? If this is not the recommended solution, is anyone familiar with a way to load an XML schema, retrieve some data then have SAP generate an XML document using the schema?
Many thanks for any help available.
THai Phillips
Try with the following Code
This program exports an internal table to an XML file.
Report ZPRUEBA_MML_13 *
Export an internal table to XML document *
NO BORRAR ESTE CODIGO *
REPORT ZPRUEBA_MML_13.
PANTALLA SELECCION *
PARAMETERS: GK_RUTA TYPE RLGRAP-FILENAME.
PANTALLA SELECCION *
TYPE TURNOS *
TYPES: BEGIN OF TURNOS,
LU LIKE T552A-TPR01,
MA LIKE T552A-TPR01,
MI LIKE T552A-TPR01,
JU LIKE T552A-TPR01,
VI LIKE T552A-TPR01,
SA LIKE T552A-TPR01,
DO LIKE T552A-TPR01,
END OF TURNOS.
TYPE TURNOS *
TYPE SOCIO *
TYPES: BEGIN OF SOCIO,
NUMERO LIKE PERNR-PERNR,
REPOSICION LIKE PA0050-ZAUVE,
NOMBRE LIKE PA0002-VORNA,
TURNOS TYPE TURNOS,
END OF SOCIO.
TYPE SOCIO *
ESTRUCTURA ACCESOS *
DATA: BEGIN OF ACCESOS OCCURS 0,
SOCIO TYPE SOCIO,
END OF ACCESOS.
ESTRUCTURA ACCESOS *
START OF SELECTION *
START-OF-SELECTION.
PERFORM LLENA_ACCESOS.
PERFORM DESCARGA_XML.
END-OF-SELECTION.
END OF SELECTION *
FORM LLENA_ACCESOS *
FORM LLENA_ACCESOS.
REFRESH ACCESOS.
CLEAR ACCESOS.
MOVE: '45050' TO ACCESOS-SOCIO-NUMERO,
'MOISES MORENO' TO ACCESOS-SOCIO-NOMBRE,
'0' TO ACCESOS-SOCIO-REPOSICION,
'T1' TO ACCESOS-SOCIO-TURNOS-LU,
'T2' TO ACCESOS-SOCIO-TURNOS-MA,
'T3' TO ACCESOS-SOCIO-TURNOS-MI,
'T4' TO ACCESOS-SOCIO-TURNOS-JU,
'T5' TO ACCESOS-SOCIO-TURNOS-VI,
'T6' TO ACCESOS-SOCIO-TURNOS-SA,
'T7' TO ACCESOS-SOCIO-TURNOS-DO.
APPEND ACCESOS.
CLEAR ACCESOS.
MOVE: '45051' TO ACCESOS-SOCIO-NUMERO,
'RUTH PEÑA' TO ACCESOS-SOCIO-NOMBRE,
'0' TO ACCESOS-SOCIO-REPOSICION,
'T1' TO ACCESOS-SOCIO-TURNOS-LU,
'T2' TO ACCESOS-SOCIO-TURNOS-MA,
'T3' TO ACCESOS-SOCIO-TURNOS-MI,
'T4' TO ACCESOS-SOCIO-TURNOS-JU,
'T5' TO ACCESOS-SOCIO-TURNOS-VI,
'T6' TO ACCESOS-SOCIO-TURNOS-SA,
'T7' TO ACCESOS-SOCIO-TURNOS-DO.
APPEND ACCESOS.
ENDFORM.
FORM LLENA_ACCESOS *
FORM DESCARGA_XML *
FORM DESCARGA_XML.
DATA: L_DOM TYPE REF TO IF_IXML_ELEMENT,
M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
G_IXML TYPE REF TO IF_IXML,
W_STRING TYPE XSTRING,
W_SIZE TYPE I,
W_RESULT TYPE I,
W_LINE TYPE STRING,
IT_XML TYPE DCXMLLINES,
S_XML LIKE LINE OF IT_XML,
W_RC LIKE SY-SUBRC.
DATA: XML TYPE DCXMLLINES.
DATA: RC TYPE SY-SUBRC,
BEGIN OF XML_TAB OCCURS 0,
D LIKE LINE OF XML,
END OF XML_TAB.
CLASS CL_IXML DEFINITION LOAD.
G_IXML = CL_IXML=>CREATE( ).
CHECK NOT G_IXML IS INITIAL.
M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
CHECK NOT M_DOCUMENT IS INITIAL.
WRITE: / 'Converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'ACCESOS'
DATAOBJECT = ACCESOS[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
IF W_RC IS INITIAL.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
W_RC.
ENDIF.
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_SIZE
FILENAME = GK_RUTA
FILETYPE = 'BIN'
TABLES
DATA_TAB = XML_TAB
EXCEPTIONS
OTHERS = 10.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
FORM DESCARGA_XML *
Thanks & regards
Sreenivasulu P -
How do I add (or insert) a node into an XML document with JSTL?
Dear all,
I am trying to use JSTL to store some data from a form into XML. However, I have read many articles in JSTL and only found that it can only be, as far as those articles are concerned, used to "read" data from XML files, but not "write" to them.
Am I missing something in JSTL? Or, if I want to write to an XML file (e.g., insert a new node, or modify a node's data), will I have to write my own bean and then use <c:usebean />?
Thanks very much in advance.
Regards,
RobertJSTL is not a programming language in and of itself. It is intended to help you to write scriptlet free JSPs.
JSP pages (by one school of thought) are intended to function as the "View" in a Model-View-Controller architecture.
Being a view, JSP pages should be able to look at things - but not touch.
The standard pattern is to go to a servlet first, which invokes the logic, and then forwards to a JSP for rendering.
Editing XML by adding new nodes etc etc is thus a function of the java code layer - servlet/action whatever you want to call it.
Giving you the power to edit XML documents via JSTL (ie on a JSP page) takes away from purity of the MVC design.
Hence why they don't provide the tags for manipulating XML, and only provide the database tags with a disclaimer that they should only be used for prototypes/trivial apps!
JSTL is designed to replace scriptlet code on a JSP page.
It can replace 99% of scriptlet code. The other 1% shouldn't be on the JSP in the first place :-)
cheers,
evnafets -
I'm am extremely new to this so if there is a link or tutorial that explains what I should be doing, please direct me there, however I was unable to locate one on this site.
Challenge:
I'm trying to build a mobile app to read a local xml file and populate a listview. Everything works perfect in the 'Live View' mode of CS5.5, but when I go to preview in Safari or Firefox all that is generated is the listview container with none of the xml loaded content.
I'm reading the xml file as text and then running it through parsexml.
I am sure there is something glaring that I am missing, but I've seen many posts on other sites (not dreamweaver specific) which have shown people struggling with how to accomplish reading a local xml file and using it in a mobile app.
Any Help, insights, suggestions or examples of how to make this work in more than just the 'Live View' will be greatly appreciated.
Many thanks in advance!
XML and Code is Below
XML:
<?xml version="1.0" encoding="utf-8"?>
<Components>
<Component Id="1" Name="TermOne" Description="Definition of term one.">
</Component>
<Component Id="2" Name="Term Two" Description="Definition of term two.">
</Component>
</Components>
CODE:
$(document).ready(function(){
$.get( "jquery-mobile/dictionary.xml", function(xml) {
var xparse = $($.parseXML(xml));
var xlines = [];
xparse.find('Component').each(function(){
var name = $(this).attr('Name');
var description = $(this).attr('Description');
xlines.push('<li>' + name + ': ' + description + '</div></li>');
$('#Dictionary').append(xlines.join(''));
$('#Dictionary').listview('refresh');
},"text");
Is there any dreamweaver expert out there who knows why this code will only render in liveview and not on the browsers?
Message was edited by: Lane HammonsThanks Murray! viewing the source code, copy/paste worked!
I tried to use the insert image object for the next rollover button...but then got another error message (thankfully just one). I know that I could simply copy the format that you did for the first button, but since this site will be image rollover intensive, I'd like to try to fix this error so I can use the design feature.
Here is the message from validator:
Line 73, Column 443: required attribute "alt" not specified
…me="familytrees" width="105" height="57" border="0" id="familytrees" /></a></p>
✉
The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the "script" element and the "alt" attribute is required for the "img" element.
Typical values for type are type="text/css" for <style> and type="text/javascript" for <script>.
I checked the document and both types have been entered - very confused. Have any recommendations?
BTW - do you think it is a good idea for me to get css/html and or javascript for dummies? Do those books really help novices, such as myself?
Your patience and help is great appreciated! -
To count the repeated entries in a XML document.
HOW TO COUNT THE REPEATED NUMBER OF ENTRIES IN A XML DOCUMENT USING THE SAP REPORT PROGRAM?
<?xml version="1.0" encoding="utf-16" ?>
- <ROOT>
- <SYSTEMDETAILS>
- <item>
<SYSDETAILSNAME>CODE</SYSDETAILSNAME>
<SYSDETAILS>00</SYSDETAILS>
</item>
- <item>
<SYSDETAILSNAME>LICENSE</SYSDETAILSNAME>
<SYSDETAILS>INITIAL</SYSDETAILS>
</item>
- <item>
<SYSDETAILSNAME>BASIS RELEASE</SYSDETAILSNAME>
<SYSDETAILS>700</SYSDETAILS>
</item>
- <item>
<SYSDETAILSNAME>SYSTEM NAME</SYSDETAILSNAME>
<SYSDETAILS>IS3</SYSDETAILS>
</item>
- <item>
<SYSDETAILSNAME>CLIENT</SYSDETAILSNAME>
<SYSDETAILS>800</SYSDETAILS>
</item>
- <item>
<SYSDETAILSNAME>LOCLANG</SYSDETAILSNAME>
<SYSDETAILS>English</SYSDETAILS>
</item>
</SYSTEMDETAILS>
- <ACH>
- <item>
<NAME>HLA0009999</NAME>
<TLEVEL>01</TLEVEL>
<TEXT>SAP</TEXT>
<TEXT4>Application Components</TEXT4>
<TEXTLOC>Application Components</TEXTLOC>
</item>
<item>
<NAME>ABA0000311</NAME>
<TLEVEL>02</TLEVEL>
<TEXT>AP</TEXT>
<TEXT4>Application Platform</TEXT4>
<TEXTLOC>Application Platform</TEXTLOC>
</item>
- <item>
<NAME>KPE0000001</NAME>
<TLEVEL>03</TLEVEL>
<TEXT>AP-PPE</TEXT>
<TEXT4>Integrated Product and Process Engineering</TEXT4>
<TEXTLOC>Integrated Product and Process Engineering</TEXTLOC>
</item>
SAY THE BOLD PART SHOWS 1 USER ,SO HOW MANY TIMES THE SAME USER APPEARS IN THE DOCUMENT.
HOW CAN I FIND THAT?If the same content of file already thr in the Internal table as 1 STRING/LINE then you can loop the internal table count the entries which one you want like
Kanagaraja L -
What is the best way to handle duplicate in an XML document?
I have an XML document that may contain duplicated nodes. I want to insert it to the DBXML database, so that the duplicated nodes are eliminated.
What would be the best way (in term of performance) to do it?
I thought of enforcing the uniqueness constraint and then insert the nodes one by one, so that I will get an exception from the database if the node is duplicated, but I may have more than 50000 nodes in the worst case, so I'm not sure if this is still a good way to do it.
Can someone give me some suggestion on this?
Thanks!Hi,
I would suggest to reconsider building of your document so that it doesn't contain duplicates if you don't need them. And it doesn't have much to do with DB XML then.
Also you could insert your document with duplicates and use XQuery Update facilities to delete undesirable nodes.
Vyacheslav
Maybe you are looking for
-
Reg:Variable Substitution in Receiver File Adapter
Hi... In the Source File, I am gtting the Field "Product_Name". Based on the Product Name, i need to map the Target Field. In The Target, I am having Filed as Folder Path. This Folder_Path is mapped based on the condition like. if Product_Name =
-
Third-party keyboard and mouse
Im buying a third-party USB keyboard and mouse, as quoted in the FAQ. I cannot afford the original keyboard and mouse because here in Brazil theyre extremely expansive. But some of these third-party sets have an indication: for both windows and
-
The help section says to view the amount of memory available for application data or for storing files on a media card, in the device options, click Memory. I don't have "Memory" as an option. When I open Blackberry App World and go to "My World", in
-
Invalid Data Type Exception Error in SAPBC
Hi All: We are using SAPBC as our middleware for communication between SAP and external billing application. We are trying to send PO in the form of IDocs (ORDERS) from SAP to the external application through SAPBC. The message type ORDERS in SAPBC h
-
MAKE TO ORDER AND VARAINT CONFIGURATION
Hi firends, What is the difference between MAKE TO ORDER and VARAINT CONFIGURATION PROCESS, in which scenarios we are using both topics. Can any one explain about steps for make to order and variant configuration. i need complete process.