Nested XML into comboBox
Well as stupid as this sounds I can populate a datagrid from
a dynamic xml source(ASP) using HTTPservice but a basic lack of
understanding is preventing me from using this data in a comboBox
Below is my application source that works for populating the
datagrid in it, but when the data is used in the comboBox as it's
dataprovider the value is "[object][object]" Ive tried a bunch of
stuff but I think im conceptualy misunderstanding something about
retreiving nested values...
--MY BROKEN EXAMPLE---
--XML-output-by-asp-document--------
<product>
<category>Tile</category>
<name>Angelic Peach</name>
</product>
<product>
<category>Tile</category>
<name>Cosmo</name>
</product>
<product>
<category>Tile</category>
<name>Durva</name>
</product>
<product>
<category>Tile</category>
<name>Isosilis</name>
</product>
<product>
<category>Tile</category>
<name>Magaloth</name>
</product>
<product>
<category>Tile</category>
<name>Trunklin</name>
</product>
<product>
<category>Tile</category>
<name>Googolfletch</name>
</product>
<product>
<category>Tile</category>
<name>Moskurbelf</name>
</product>
<product>
<category>Tile</category>
<name>DoChoaKoa</name>
</product>
---products-component-for-use-in-main-application---
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="
http://www.adobe.com/2006/mxml"
width="400" height="300"
creationComplete="this.productStream.send();">
<mx:Script>
<![CDATA[
import mx.utils.ArrayUtil;
import mx.utils.XMLUtil
//var urlPath="
http://localhost/rogerwilko/AndeanStone/xml.asp";
function xmlRequest():void {
// Cancel all previous pending calls.
productStream.cancel();
var params:Object = new Object();
params.func = 'products';
productStream.send(params);
]]>
</mx:Script>
<mx:HTTPService id="productStream"
url="
http://localhost/rogerwilko/AndeanStone/xml.asp"/>
<mx:Label text="Select A Product Category" top="0"
left="0"/>
<mx:ComboBox id="prodCatList"
dataProvider="{mx.utils.ArrayUtil.toArray(this.productStream.lastResult.product)}"
width="200" left="0" top="20" cornerRadius="3" fillAlphas="[0.5,
0.5]" themeColor="#00ff00" alpha="0.49">
</mx:ComboBox>
<mx:DataGrid id="prodList"
dataProvider="{mx.utils.ArrayUtil.toArray(this.productStream.lastResult.product)}"
columnWidth="200" width="200" left="0" top="55">
<mx:columns>
<mx:DataGridColumn headerText="{prodCatList.value}"
dataField="name"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>
Thanks in advance for any help you can provide me
leo
You will need to specify either a labelField or
labelFunction. You can use a labelField if the value you want to
show in the combo box is a first level property of the item.
If the data you want to display is deeper in the item object,
and you need to "dot down" to get it use a labelFunction.
HTTPService resultFormat defaults to Object. I have never
been comfortable about the way Flex converts xml into objects, so I
always use e4x. This choice affects the structure of your item
objects, and therefore the way you need to access the item objects
properties.
Try labelField, anif that doesn't work use a labelFunction.
Note, you can debug the labelFunction quite handily.
Tracy
Similar Messages
-
Hello, could anyone help me on this? I have a XML file as below:
<Feed>
<svc>enr1</svc>
<report_email>[email protected]</report_email>
<requisition id="12">
<email>[email protected]</email>
<Name>Joseph</Name>
<PRODUCT>
<PROD_ID>532343234</PROD_ID>
<NAME>KID'S WEAR </NAME>
<DATE_ORDERED>09/04/2009</DATE_ORDERED>
</PRODUCT>
<PRODUCT>
<PROD_ID>67045434</PROD_ID>
<NAME>SHOES</NAME>
<DATE_ORDERED>09/04/2009</DATE_ORDERED>
</PRODUCT>
</requisition>
<requisition id="13">
<email>[email protected]</email>
<Name>Sarah</Name>
<PRODUCT>
<PROD_ID>11111111</PROD_ID>
<NAME>LOST IN FOREST</NAME>
<DATE_ORDERED>10/05/2008</DATE_ORDERED>
</PRODUCT>
<PRODUCT>
<PROD_ID>222222222</PROD_ID>
<NAME>TRY IT NOW</NAME>
<DATE_ORDERED>09/04/2007</DATE_ORDERED>
</PRODUCT>
</requisition>
</Feed>You could flatten the XML into table style output using XMLTABLE...
WITH t as (select XMLTYPE('
<RECSET>
<REC>
<COUNTRY>1</COUNTRY>
<POINT>1800</POINT>
<USER_INFO>
<USER_ID>1</USER_ID>
<TARGET>28</TARGET>
<STATE>6</STATE>
<TASK>12</TASK>
</USER_INFO>
<USER_INFO>
<USER_ID>5</USER_ID>
<TARGET>19</TARGET>
<STATE>1</STATE>
<TASK>90</TASK>
</USER_INFO>
</REC>
<REC>
<COUNTRY>2</COUNTRY>
<POINT>2400</POINT>
<USER_INFO>
<USER_ID>3</USER_ID>
<TARGET>14</TARGET>
<STATE>7</STATE>
<TASK>5</TASK>
</USER_INFO>
</REC>
</RECSET>') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task
from t
,XMLTABLE('/RECSET/REC'
PASSING t.xml
COLUMNS country NUMBER PATH '/REC/COUNTRY'
,point NUMBER PATH '/REC/POINT'
,user_info XMLTYPE PATH '/REC/*'
) x
,XMLTABLE('/USER_INFO'
PASSING x.user_info
COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
,target NUMBER PATH '/USER_INFO/TARGET'
,state NUMBER PATH '/USER_INFO/STATE'
,task NUMBER PATH '/USER_INFO/TASK'
) y
COUNTRY POINT USER_ID TARGET STATE TASK
1 1800 1 28 6 12
1 1800 5 19 1 90
2 2400 3 14 7 5Or you could shread the XML into Oracle nested tables...
e.g.
(Based on response from mdrake on this thread: Re: XML file processing into oracle
Reading XML using a schema...
declare
SCHEMAURL VARCHAR2(256) := 'http://xmlns.example.org/xsd/testcase.xsd';
XMLSCHEMA VARCHAR2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb" xdb:storeVarrayAsTable="true">
<xs:element name="cust_order" type="cust_orderType" xdb:defaultTable="CUST_ORDER_TBL"/>
<xs:complexType name="groupType" xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="item" type="itemType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:byte" use="required"/>
</xs:complexType>
<xs:complexType name="itemType" xdb:maintainDOM="false">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="id" type="xs:short" use="required"/>
<xs:attribute name="name" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="cust_orderType" xdb:maintainDOM="false">
<xs:sequence>
<xs:element name="group" type="groupType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="cust_id" type="xs:short" use="required"/>
</xs:complexType>
</xs:schema>';
INSTANCE CLOB :=
'<cust_order cust_id="12345">
<group id="1">
<item id="1" name="Standard Mouse">100</item>
<item id="2" name="Keyboard">100</item>
<item id="3" name="Memory Module 2Gb">200</item>
<item id="4" name="Processor 3Ghz">25</item>
<item id="5" name="Processor 2.4Ghz">75</item>
</group>
<group id="2">
<item id="1" name="Graphics Tablet">15</item>
<item id="2" name="Keyboard">15</item>
<item id="3" name="Memory Module 4Gb">15</item>
<item id="4" name="Processor Quad Core 2.8Ghz">15</item>
</group>
<group id="3">
<item id="1" name="Optical Mouse">5</item>
<item id="2" name="Ergo Keyboard">5</item>
<item id="3" name="Memory Module 2Gb">10</item>
<item id="4" name="Processor Dual Core 2.4Ghz">5</item>
<item id="5" name="Dual Output Graphics Card">5</item>
<item id="6" name="28inch LED Monitor">10</item>
<item id="7" name="Webcam">5</item>
<item id="8" name="A3 1200dpi Laser Printer">2</item>
</group>
</cust_order>';
begin
dbms_xmlschema.registerSchema
schemaurl => SCHEMAURL
,schemadoc => XMLSCHEMA
,local => TRUE
,genTypes => TRUE
,genBean => FALSE
,genTables => TRUE
,ENABLEHIERARCHY => DBMS_XMLSCHEMA.ENABLE_HIERARCHY_NONE
execute immediate 'insert into CUST_ORDER_TBL values (XMLTYPE(:INSTANCE))' using INSTANCE;
end;
desc CUST_ORDER_TBL
SQL> desc CUST_ORDER_TBL
Name Null? Type
TABLE of SYS.XMLTYPE(XMLSchema "http://xmlns.example.org/xsd/testcase.xsd" Element "cust_order") STORAGE Object-relational TYPE "cust_orderType222_T"
set autotrace on explain
set pages 60 lines 164 heading on
col cust_id format a8
select extract(object_value,'/cust_order/@cust_id') as cust_id
,grp.id as group_id, itm.id as item_id, itm.inm as item_name, itm.qty as item_qty
from CUST_ORDER_TBL
,XMLTABLE('/cust_order/group'
passing object_value
columns id number path '@id'
,item xmltype path 'item'
) grp
,XMLTABLE('/item'
passing grp.item
columns id number path '@id'
,inm varchar2(30) path '@name'
,qty number path '.'
) itm
CUST_ID GROUP_ID ITEM_ID ITEM_NAME ITEM_QTY
12345 1 1 Standard Mouse 100
12345 1 2 Keyboard 100
12345 1 3 Memory Module 2Gb 200
12345 1 4 Processor 3Ghz 25
12345 1 5 Processor 2.4Ghz 75
12345 2 1 Graphics Tablet 15
12345 2 2 Keyboard 15
12345 2 3 Memory Module 4Gb 15
12345 2 4 Processor Quad Core 2.8Ghz 15
12345 3 1 Optical Mouse 5
12345 3 2 Ergo Keyboard 5
12345 3 3 Memory Module 2Gb 10
12345 3 4 Processor Dual Core 2.4Ghz 5
12345 3 5 Dual Output Graphics Card 5
12345 3 6 28inch LED Monitor 10
12345 3 7 Webcam 5
12345 3 8 A3 1200dpi Laser Printer 2
17 rows selected.Need at least 10.2.0.3 for performance i.e. to avoid COLLECTION ITERATOR PICKLER FETCH in execution plan...
On 10.2.0.1:
Execution Plan
Plan hash value: 3741473841
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 24504 | 89M| 873 (1)| 00:00:11 |
| 1 | NESTED LOOPS | | 24504 | 89M| 873 (1)| 00:00:11 |
| 2 | NESTED LOOPS | | 3 | 11460 | 805 (1)| 00:00:10 |
| 3 | TABLE ACCESS FULL | CUST_ORDER_TBL | 1 | 3777 | 3 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | SYS_IOT_TOP_774117 | 3 | 129 | 1 (0)| 00:00:01 |
| 5 | COLLECTION ITERATOR PICKLER FETCH| XMLSEQUENCEFROMXMLTYPE | | | | |
Predicate Information (identified by operation id):
4 - access("NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
filter("SYS_NC_TYPEID$" IS NOT NULL)
Note
- dynamic sampling used for this statementOn 10.2.0.3:
Execution Plan
Plan hash value: 1048233240
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 17 | 132K| 839 (0)| 00:00:11 |
| 1 | NESTED LOOPS | | 17 | 132K| 839 (0)| 00:00:11 |
| 2 | MERGE JOIN CARTESIAN | | 17 | 131K| 805 (0)| 00:00:10 |
| 3 | TABLE ACCESS FULL | CUST_ORDER_TBL | 1 | 3781 | 3 (0)| 00:00:01 |
| 4 | BUFFER SORT | | 17 | 70839 | 802 (0)| 00:00:10 |
|* 5 | INDEX FAST FULL SCAN| SYS_IOT_TOP_56154 | 17 | 70839 | 802 (0)| 00:00:10 |
|* 6 | INDEX UNIQUE SCAN | SYS_IOT_TOP_56152 | 1 | 43 | 2 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | SYS_C006701 | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
5 - filter("SYS_NC_TYPEID$" IS NOT NULL)
6 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
w5Ysl6x9w=="."SYS_NC0000600007$")
filter("SYS_NC_TYPEID$" IS NOT NULL AND
"NESTED_TABLE_ID"="CUST_ORDER_TBL"."SYS_NC0000900010$")
7 - access("SYS_NTpzENS1H/RwSSC7TVzvlqmQ=="."NESTED_TABLE_ID"="SYS_NTnN5b8Q+8Txi9V
w5Ysl6x9w=="."SYS_NC0000600007$")
Note
- dynamic sampling used for this statementCLEAN UP...
DROP TABLE CUST_ORDER_TBL purge;
exec dbms_xmlschema.deleteschema('http://xmlns.example.org/xsd/testcase.xsd'); -
I'm working on a tree navigation that needs to have some data provided in a nested xml format
<node label="California">
<node label="location 1" />
<node label="location 2">
<node label="option 1" />
<node label="option 2" />
</node>
</node>
But the data that I'm getting (and probably can't change) is coming out flat:
<item>
<id>12</id>
<label>California</label>
</item>
<item>
<id>15</id>
<label>location 1</label>
<parent>12</parent>
</item>
<item>
<id>17</id>
<label>location 2</label>
<parent>12</parent>
</item>
<item>
<id>33</id>
<label>option 1</label>
<parent>17</parent>
</item>
<item>
<id>70</id>
<label>loption 2</label>
<parent>17</parent>
</item>
Any suggestions on how to change that data from what I'm supplied to what I need? Is it just a brute force looping through the xml nodes a bunch of times? Or is there a clever way that I'm not seeing?If you are sure about data integrity, especially ids relationships, the following is one of the ways to reposition nodes without changing general node structure. Following this logic you can restructure XML altogether.
With that said, I am not sure XML restructuring is the best way to go anyway. I feel a much better solution would be to parse XML into a more native to AS3 structure like Array, Object or Vector. I would rather create a specialized data provider class.
Example uses the following XML:
<items>
<item>
<id>1</id>
<label>California</label>
</item>
<item>
<id>2</id>
<label>California location 1</label>
<parent>1</parent>
</item>
<item>
<id>3</id>
<label>California location 1 option 1</label>
<parent>2</parent>
</item>
<item>
<id>4</id>
<label>California location 1 option 2</label>
<parent>2</parent>
</item>
<item>
<id>5</id>
<label>California location 1 option 3</label>
<parent>2</parent>
</item>
<item>
<id>6</id>
<label>California location 2</label>
<parent>1</parent>
</item>
<item>
<id>7</id>
<label>California location 2 option 1</label>
<parent>6</parent>
</item>
<item>
<id>8</id>
<label>California location 2 option 2</label>
<parent>6</parent>
</item>
<item>
<id>9</id>
<label>New York</label>
</item>
<item>
<id>10</id>
<label>New York location 1</label>
<parent>9</parent>
</item>
<item>
<id>11</id>
<label>New York location 1 option 1</label>
<parent>10</parent>
</item>
<item>
<id>12</id>
<label>New York location 1 option 1</label>
<parent>10</parent>
</item>
</items>
Code that parses this xml is (given the value of the xml above is assigned to var xml:XML
var parent:XMLList;
for each (var node:XML in xml.item)
if (node.parent.toString() != "")
parent = xml.item.(id == node.parent.toString());
if (parent.parent.toString() == "")
parent.@["type"] = "top";
node.@["type"] = "child";
parent.appendChild(node);
xml = new XML(xml.toString());
while (xml.item.(@type == "child").length() > 0)
delete xml.item.(@type == "child")[0];
trace(xml);
Output is:
<items>
<item type="top">
<id>1</id>
<label>California</label>
<item type="child">
<id>2</id>
<label>California location 1</label>
<parent>1</parent>
<item type="child">
<id>3</id>
<label>California location 1 option 1</label>
<parent>2</parent>
</item>
<item type="child">
<id>4</id>
<label>California location 1 option 2</label>
<parent>2</parent>
</item>
<item type="child">
<id>5</id>
<label>California location 1 option 3</label>
<parent>2</parent>
</item>
</item>
<item type="child">
<id>6</id>
<label>California location 2</label>
<parent>1</parent>
<item type="child">
<id>7</id>
<label>California location 2 option 1</label>
<parent>6</parent>
</item>
<item type="child">
<id>8</id>
<label>California location 2 option 2</label>
<parent>6</parent>
</item>
</item>
</item>
<item type="top">
<id>9</id>
<label>New York</label>
<item type="child">
<id>10</id>
<label>New York location 1</label>
<parent>9</parent>
<item type="child">
<id>11</id>
<label>New York location 1 option 1</label>
<parent>10</parent>
</item>
<item type="child">
<id>12</id>
<label>New York location 1 option 1</label>
<parent>10</parent>
</item>
</item>
</item>
</items> -
Can't Figure Out How To Import XML into a Table?
HELP!
I've been using InDesign for several years now... but everything Ive ever done has been basic one off layout concepts.
I am working on a website for a musical theater actress and for her resume, Id like to make a PDF which lists in table format the show, theatre and role she had for each job.
I could do this manually... but Id really like to learn how to just reuse the same XML data that I have for her website and import it into InDesign.
I have looked at Adobe's help file, I have scoured the internet, and I still can't figure it out... I have done like the adobe support file says... and I cant seem to get the values I create in her resume xml file to show up in a table I create in InDesign.
I even tried to simplify it for the learning process and did something as basic as an XML file that has 5 colors... couldnt even get that working.
So could someone explain it to me like Im a 5 year old... how to take a XML file, import it, place it in a table and have the data actually show up in the table.
thanks,
brianAre you sure you want to use XML with tables for this? No doubt importing XML into tables is useful for some specialized tasks, such as importing formatting information inside the XML itself, but for most of the familiar tasks that XML excels at, tables are neither necessary nor useful.
In my (limited) experience, if the XML elements are well-differentiated, by which I mean different types of data have their own distinctive tags, then the special powers of XML can be exploited more fully using the more familiar tagged text, nested tags etc. in ordinary text frames using paragraph breaks, tab characters, etc. to achieve a suitably "tabular" finished appearance.
If you must import XML into tables, I recommend Adobe's own PDF "Adobe InDesign CS3 and XML: A Technical Reference" availabe here:
http://www.adobe.com/designcenter/indesign/articles/indcs3ip_xmlrules.pdf
It sounds very daunting -- the words "technical reference" make me shudder -- but actually it's very readable and not very technical at all. Some nice pics and everything!
Jeremy -
Spry Menu Using Nested XML Dataset (Spry 1.6)
I have a vertical menu with a few items. One of which is
labeled Products which has submenus. I want to have that submenu
read from a Nested XML dataset. Using a single dataset for one
level in a menu is easy enough, but the subenu will have submenus.
Example Menu:
Home
Company
Products
|-- Product 1
|-- Item 1
|-- Item 2
|-- Item 3
|-- Product 2
|-- Item 1
|-- Item 2
|-- Product 3
|-- Item 1
|-- Item 2
|-- Item 3
|-- Item 4
|-- Product 4
|-- Item 1
|-- Item 2
|-- Product 5
I have been looking for an easy way to use the Spry Nested
XML Dataset to create the Product/Item menu. The number of Products
may vary as well as the number of Items in each Product submenu
(also, some Products may not have Items).
I already have an ASP page that creates the XML data from a
database.
Schema follows (XSD ):
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema">
<xsd:element name="products">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="product_type"
maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="type_name" maxOccurs="1"
type="xsd:string"/>
<xsd:element name="type_url" maxOccurs="1"
type="xsd:anyURI"/>
<xsd:element name="product_name"
maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item_name" maxOccurs="1"
type="xsd:string"/>
<xsd:element name="item_url" maxOccurs="1"
type="xsd:anyURI"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
I have been programming for 17 years but am new to Spry. If
this cannot be done easily with the Spry framework, I'll probably
wind up splitting the XML data into 2 files (Products and Items)
then writing a nested loop and call each by row, but then I have to
find out how Spry Datasets reference XML data. Figuring out how to
call rows from the XML data shouldn't be so bad, but this method
just seems like such a hassle for something that should be easy.
Pseudocode follows:
j=1
i=1 to TotalNumberProducts
display Product i from Products
ItemsExist=true
While ItemsExist
if j > TotalNumberItems | Item j is not for Product then
ItemsExist=false
else
display Item j from Items
j++
Wend
Next
Thanks in advance for any help or direction!That's exactly what I'm trying to do. However, I implemented
that code and the submenus won't appear. I suspect the submenus
aren't finding the field names from the Nested XML Dataset. The
first level of Product menus work great (this is a submenu of the
overall menu) and correctly identify products that do not have
submenus, so I know it's picking up the number of records in the
Nested Dataset correctly - it just won't display the data in the
next level of menu.
variable and script declarations:
<script src="SpryAssets/SpryMenuBar.js"
type="text/javascript"></script>
<script src="SpryAssets/xpath.js"
type="text/javascript"></script>
<script src="SpryAssets/SpryData.js"
type="text/javascript"></script>
<script src="SpryAssets/SpryNestedXMLDataSet.js"
type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarVertical.css"
rel="stylesheet" type="text/css">
<script type="text/javascript">
<!--
var productMenuData = new
Spry.Data.XMLDataSet("products.asp", "products/product_type");
var productMenuDataItems = new
Spry.Data.NestedXMLDataSet(productMenuData, "product_name");
//-->
</script>
Code for menus:
<ul id="NavMenu" class="MenuBarVertical">
<li><a
href="index.html">Home</a></li>
<li><a
href="company.html">Company</a></li>
<li><a href="franco_giberti.html">Franco
Giberti</a></li>
<li><a class="MenuBarItemSubmenu"
href="products.asp">Products</a>
<ul spry:region="productMenuData
productMenuDataItems">
<li spry:repeat="productMenuData"><a
class="MenuBarItemSubmenu" href="{type_url}"
spry:if="{productMenuDataItems::ds_RowCount} !=
0">{type_name}</a> <a href="{type_url}"
spry:if="{productMenuDataItems::ds_RowCount} ==
0">{type_name}</a>
<ul spry:if="{productMenuDataItems::ds_RowCount} !=
0">
<li spry:repeat="productMenuDataItems"><a
href="{productMenuDataItems::item_url}">{productMenuDataItems::item_name}</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="contact.html">Contact Us</a>
<!-- end #sidebar1 -->
</li>
</ul>
XML:
<products
xsi:noNameSpaceSchemaLocation="products.xsd">
−
<product_type>
<type_name>Pasta Sauce</type_name>
<type_url>pt_2.asp</type_url>
−
<product_name>
<item_name>Putenesca</item_name>
<item_url>pn_3.asp</item_url>
</product_name>
−
<product_name>
<item_name>Arrabiata</item_name>
<item_url>pn_4.asp</item_url>
</product_name>
−
<product_name>
<item_name>Pesto</item_name>
<item_url>pn_5.asp</item_url>
</product_name>
−
<product_name>
<item_name>Basil and Tomato</item_name>
<item_url>pn_6.asp</item_url>
</product_name>
−
<product_name>
<item_name>Bolognese</item_name>
<item_url>pn_7.asp</item_url>
</product_name>
−
<product_name>
<item_name>Carboniera</item_name>
<item_url>pn_8.asp</item_url>
</product_name>
</product_type>
+
<product_type>
<type_name>Organic Olive Oil</type_name>
<type_url>pt_3.asp</type_url>
−
<product_name>
<item_name>Original</item_name>
<item_url>pn_9.asp</item_url>
</product_name>
−
<product_name>
<item_name>Basil</item_name>
<item_url>pn_10.asp</item_url>
</product_name>
−
<product_name>
<item_name>Herbs</item_name>
<item_url>pn_11.asp</item_url>
</product_name>
−
<product_name>
<item_name>Sun Dried Tomato</item_name>
<item_url>pn_12.asp</item_url>
</product_name>
</product_type>
+
<product_type>
<type_name>Organic Spreads</type_name>
<type_url>pt_4.asp</type_url>
−
<product_name>
<item_name>Putenesca</item_name>
<item_url>pn_13.asp</item_url>
</product_name>
−
<product_name>
<item_name>Arrabiata</item_name>
<item_url>pn_14.asp</item_url>
</product_name>
−
<product_name>
<item_name>Pesto</item_name>
<item_url>pn_15.asp</item_url>
</product_name>
−
<product_name>
<item_name>Basil and Tomato</item_name>
<item_url>pn_16.asp</item_url>
</product_name>
−
<product_name>
<item_name>Bolognese</item_name>
<item_url>pn_17.asp</item_url>
</product_name>
−
<product_name>
<item_name>Carboniera</item_name>
<item_url>pn_18.asp</item_url>
</product_name>
</product_type>
+
<product_type>
<type_name>Organic Grilled Vegetables</type_name>
<type_url>pt_5.asp</type_url>
−
<product_name>
<item_name>Putenesca</item_name>
<item_url>pn_19.asp</item_url>
</product_name>
−
<product_name>
<item_name>Arrabiata</item_name>
<item_url>pn_20.asp</item_url>
</product_name>
−
<product_name>
<item_name>Pesto</item_name>
<item_url>pn_21.asp</item_url>
</product_name>
−
<product_name>
<item_name>Basil and Tomato</item_name>
<item_url>pn_22.asp</item_url>
</product_name>
−
<product_name>
<item_name>Bolognese</item_name>
<item_url>pn_23.asp</item_url>
</product_name>
−
<product_name>
<item_name>Carboniera</item_name>
<item_url>pn_24.asp</item_url>
</product_name>
</product_type>
−
<product_type>
<type_name>Truffle Products</type_name>
<type_url>pt_6.asp</type_url>
</product_type>
</products>
Any further guidance would be very much appreciated! -
How to construct the where clause for a nested xml target file
Post Author: jlpete72
CA Forum: Data Integration
I'm having some problems getting the desired results creating a multi-level nested xml file. Specifically, it does not seem that the where clause in the child schemas respects values from parent schemas. I'm sure I'm constructing something incorrectly, but am running out of ideas.
I am working with the classic company/order/line hierarchy and there are three levels of output schemas in my target xml file, one for company, order header and order line information.
For testing, I have hardcoded a restriction at the order header line to deal with only one order. But unless I hardcode values into the where clause at the order line level of the schema, all values are returned for orders belonging to the company defined in the company level.
I'm trying a where clause at the order line level similar to:
order_line.customer = order_header.customer and order_line.order_num = order_header.order_num
If the customer has more than one order in the data file, then all orders for that customer are placed in the detail for the order header. Only if I hard code the order number in the where clause do I get only the lines for the order specified in the header section. Not very practical.
What am I missing?An External Parsed Entity could be used to reference a schema.
In your DTD:
<!ENTITY datamodules SYSTEM "file:///c:/Datamodules/Datamodules.xsd">
Refer the external entity in xml document:
<datamodules>&datamodules;</datamodules> -
How to generate nested xml/ complex xml in Oracle 8i using 8i packages dbms_xmlquery or xmlgen .
The xml might be looked like this..
if any body have idea then pls let me know.
i am trying to write Stored procedure on that i am using query like select c1,c2, cursor(c3,c4 from xyb) from ABC
but not getting required output
<?xml version="1.0" ?>
- <File>
<File_Type>ETNL_TRAVELR_PAYMENTS</File_Type>
- <File_Header_Record>
<File_Format_Version>0002</File_Format_Version>
<Creation_Module />
</File_Header_Record>
- <Transaction>
<Transaction_Type>FT_TRANS_IMP</Transaction_Type>
- <Transaction_Header>
<Record_Number>1</Record_Number>
<Urgent>N</Urgent>
</Transaction_Header>
- <Model_Info>
- <Model_ID>
- <![CDATA[ FF DOM EXT PAY
]]>
</Model_ID>
</Model_Info>
- <Transfer_Info>
<Charges>15</Charges>
</Transfer_Info>
- <Amounts>
- <Transaction_Amount>
<Amount>154.00</Amount>
<Currency>GBP</Currency>
</Transaction_Amount>
</Amounts>
- <Dates>
<Trusted_Source>N</Trusted_Source>
<Value_Date />
</Dates>
- <Bank_Account>
<Bank_Account_Type>DR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>K</Code_Type>
</Bank_Route_Code>
</Bank>
- <Account>
<Account_ID>D562</Account_ID>
</Account>
</Bank_Account>
- <Bank_Account>
<Bank_Account_Type>CR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>K</Code_Type>
- <Code>
- <![CDATA[ 538111
]]>
</Code>
</Bank_Route_Code>
- <Bank_Address_Info>
- <Name>
- <![CDATA[ Natwest
]]>
</Name>
- <Street1>
- <![CDATA[ Long Sutton Branch
]]>
</Street1>
- <Street2>
- <![CDATA[ 25 market Place
]]>
</Street2>
- <City>
- <![CDATA[ Spalding
]]>
</City>
<Country>GB</Country>
</Bank_Address_Info>
</Bank>
- <Account>
- <Account_Number>
- <![CDATA[ 12345678
]]>
</Account_Number>
- <Account_Address_Info>
- <Name>
- <![CDATA[ John Doe
]]>
</Name>
- <Street1>
- <![CDATA[ Employee Addr1
]]>
</Street1>
- <Street2>
- <![CDATA[ Employee Addr2
]]>
</Street2>
- <City>
- <![CDATA[ EmployeeCity
]]>
</City>
<Country_Sub_Entity />
<Postal>CF375YL</Postal>
<Country>GB</Country>
</Account_Address_Info>
</Account>
</Bank_Account>
- <Payment_Details_Or_Addenda>
- <Details_Text>
- <![CDATA[ PAY OHRID: 100000999
]]>
</Details_Text>
</Payment_Details_Or_Addenda>
- <Comments>
- <Comment_Text>
- <![CDATA[ NONE
]]>
</Comment_Text>
</Comments>
- <References>
- <Reference>
<Reference_Type>FBNF</Reference_Type>
- <Reference_Value>
- <![CDATA[ INVOICE 20021004001542
]]>
</Reference_Value>
</Reference>
- <Reference>
<Reference_Type />
- <Reference_Value>
- <![CDATA[
]]>
</Reference_Value>
</Reference>
- <Reference>
<Reference_Type>FMAILEN</Reference_Type>
- <Reference_Value>
- <![CDATA[ [email protected]
]]>
</Reference_Value>
</Reference>
</References>
</Transaction>
+ <Transaction>
<Transaction_Type>FT_TRANS_IMP</Transaction_Type>
+ <Transaction_Header>
<Record_Number>2</Record_Number>
<Urgent>N</Urgent>
</Transaction_Header>
+ <Model_Info>
- <Model_ID>
- <![CDATA[ FF DOM EXT PAY
]]>
</Model_ID>
</Model_Info>
+ <Transfer_Info>
<Charges>15</Charges>
</Transfer_Info>
- <Amounts>
- <Transaction_Amount>
<Amount>46.00</Amount>
<Currency>EUR</Currency>
</Transaction_Amount>
</Amounts>
- <Dates>
<Trusted_Source>N</Trusted_Source>
<Value_Date />
</Dates>
- <Bank_Account>
<Bank_Account_Type>DR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>G</Code_Type>
</Bank_Route_Code>
</Bank>
- <Account>
<Account_ID>D202</Account_ID>
</Account>
</Bank_Account>
- <Bank_Account>
<Bank_Account_Type>CR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>G</Code_Type>
- <Code>
- <![CDATA[ 234543
]]>
</Code>
</Bank_Route_Code>
- <Bank_Address_Info>
- <Name>
- <![CDATA[
]]>
</Name>
- <Street1>
- <![CDATA[
]]>
</Street1>
- <Street2>
- <![CDATA[
]]>
</Street2>
- <City>
- <![CDATA[
]]>
</City>
<Country />
</Bank_Address_Info>
</Bank>
- <Account>
- <Account_Number>
- <![CDATA[ DE65100700000123456789
]]>
</Account_Number>
- <Account_Address_Info>
- <Name>
- <![CDATA[ Test User
]]>
</Name>
- <Street1>
- <![CDATA[ Employee Addr1
]]>
</Street1>
- <Street2>
- <![CDATA[ Employee Addr2
]]>
</Street2>
- <City>
- <![CDATA[ Berlin
]]>
</City>
<Country_Sub_Entity />
<Postal>1234323</Postal>
<Country>DE</Country>
</Account_Address_Info>
</Account>
</Bank_Account>
- <Payment_Details_Or_Addenda>
- <Details_Text>
- <![CDATA[ PAY OHRID: 100000888
]]>
</Details_Text>
</Payment_Details_Or_Addenda>
- <Comments>
- <Comment_Text>
- <![CDATA[ NONE
]]>
</Comment_Text>
</Comments>
- <References>
- <Reference>
<Reference_Type>FBNF</Reference_Type>
- <Reference_Value>
- <![CDATA[ INVOICE 20021101001053
]]>
</Reference_Value>
</Reference>
- <Reference>
<Reference_Type />
- <Reference_Value>
- <![CDATA[
]]>
</Reference_Value>
</Reference>
- <Reference>
<Reference_Type>FMAILEN</Reference_Type>
- <Reference_Value>
- <![CDATA[ [email protected]
]]>
</Reference_Value>
</Reference>
</References>
</Transaction>
+ <Transaction>
<Transaction_Type>FT_TRANS_IMP</Transaction_Type>
+ <Transaction_Header>
<Record_Number>3</Record_Number>
<Urgent>N</Urgent>
</Transaction_Header>
+ <Model_Info>
- <Model_ID>
- <![CDATA[ FF INTL EXT PAY
]]>
</Model_ID>
</Model_Info>
+ <Transfer_Info>
<Charges>15</Charges>
</Transfer_Info>
+ <Amounts>
+ <Transaction_Amount>
<Amount>265.00</Amount>
<Currency>EUR</Currency>
</Transaction_Amount>
</Amounts>
+ <Dates>
<Trusted_Source>N</Trusted_Source>
<Value_Date />
</Dates>
+ <Bank_Account>
<Bank_Account_Type>DR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>S</Code_Type>
</Bank_Route_Code>
</Bank>
- <Account>
<Account_ID>D202</Account_ID>
</Account>
</Bank_Account>
+ <Bank_Account>
<Bank_Account_Type>CR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>S</Code_Type>
- <Code>
- <![CDATA[
]]>
</Code>
</Bank_Route_Code>
+ <Bank_Address_Info>
- <Name>
- <![CDATA[
]]>
</Name>
- <Street1>
- <![CDATA[
]]>
</Street1>
- <Street2>
- <![CDATA[
]]>
</Street2>
- <City>
- <![CDATA[
]]>
</City>
<Country />
</Bank_Address_Info>
</Bank>
+ <Account>
- <Account_Number>
- <![CDATA[ NL02ABNA0123456789
]]>
</Account_Number>
- <Account_Address_Info>
- <Name>
- <![CDATA[ New User
]]>
</Name>
- <Street1>
- <![CDATA[ Employee Addr1
]]>
</Street1>
- <Street2>
- <![CDATA[ Employee Addr2
]]>
</Street2>
- <City>
- <![CDATA[ Ansterdam
]]>
</City>
<Country_Sub_Entity />
<Postal>34242</Postal>
<Country>NL</Country>
</Account_Address_Info>
</Account>
</Bank_Account>
+ <Payment_Details_Or_Addenda>
- <Details_Text>
- <![CDATA[ PAY OHRID: 100000777
]]>
</Details_Text>
</Payment_Details_Or_Addenda>
+ <Comments>
+ <Comment_Text>
- <![CDATA[ NONE
]]>
</Comment_Text>
</Comments>
+ <References>
+ <Reference>
<Reference_Type>FBNF</Reference_Type>
- <Reference_Value>
- <![CDATA[ INVOICE 20021101001025
]]>
</Reference_Value>
</Reference>
+ <Reference>
<Reference_Type />
- <Reference_Value>
- <![CDATA[
]]>
</Reference_Value>
</Reference>
+ <Reference>
<Reference_Type>FMAILEN</Reference_Type>
- <Reference_Value>
- <![CDATA[ [email protected]
]]>
</Reference_Value>
</Reference>
</References>
</Transaction>
+ <Transaction>
<Transaction_Type>FT_TRANS_IMP</Transaction_Type>
- <Transaction_Header>
<Record_Number>4</Record_Number>
<Urgent>N</Urgent>
</Transaction_Header>
- <Model_Info>
- <Model_ID>
- <![CDATA[ FF INTL EXT PAY
]]>
</Model_ID>
</Model_Info>
- <Transfer_Info>
<Charges>15</Charges>
</Transfer_Info>
- <Amounts>
- <Transaction_Amount>
<Amount>34.70</Amount>
<Currency>EUR</Currency>
</Transaction_Amount>
</Amounts>
- <Dates>
<Trusted_Source>N</Trusted_Source>
<Value_Date />
</Dates>
- <Bank_Account>
<Bank_Account_Type>DR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>S</Code_Type>
</Bank_Route_Code>
</Bank>
- <Account>
<Account_ID>D202</Account_ID>
</Account>
</Bank_Account>
- <Bank_Account>
<Bank_Account_Type>CR</Bank_Account_Type>
- <Bank>
- <Bank_Route_Code>
<Code_Type>S</Code_Type>
- <Code>
- <![CDATA[
]]>
</Code>
</Bank_Route_Code>
- <Bank_Address_Info>
- <Name>
- <![CDATA[
]]>
</Name>
- <Street1>
- <![CDATA[
]]>
</Street1>
- <Street2>
- <![CDATA[
]]>
</Street2>
- <City>
- <![CDATA[
]]>
</City>
<Country />
</Bank_Address_Info>
</Bank>
- <Account>
- <Account_Number>
- <![CDATA[ FR313000400828000123456789
]]>
</Account_Number>
- <Account_Address_Info>
- <Name>
- <![CDATA[ French User
]]>
</Name>
- <Street1>
- <![CDATA[ Employee Addr1
]]>
</Street1>
- <Street2>
- <![CDATA[ Employee Addr2
]]>
</Street2>
- <City>
- <![CDATA[ Paris
]]>
</City>
<Country_Sub_Entity />
<Postal>54333</Postal>
<Country>FR</Country>
</Account_Address_Info>
</Account>
</Bank_Account>
- <Payment_Details_Or_Addenda>
- <Details_Text>
- <![CDATA[ PAY OHRID: 100000666
]]>
</Details_Text>
</Payment_Details_Or_Addenda>
- <Comments>
- <Comment_Text>
- <![CDATA[ NONE
]]>
</Comment_Text>
</Comments>
- <References>
- <Reference>
<Reference_Type>FBNF</Reference_Type>
- <Reference_Value>
- <![CDATA[ INVOICE 20021101001481
]]>
</Reference_Value>
</Reference>
- <Reference>
<Reference_Type />
- <Reference_Value>
- <![CDATA[
]]>
</Reference_Value>
</Reference>
- <Reference>
<Reference_Type>FMAILEN</Reference_Type>
- <Reference_Value>
- <![CDATA[ [email protected]
]]>
</Reference_Value>
</Reference>
</References>
</Transaction>
- <File_Trailer_Record>
<File_Name>ETNL_TRAVELR_PAYMENTS</File_Name>
<Total_Records>4</Total_Records>
</File_Trailer_Record>
</File>
regards
Ramashankar SahuAs I recall from my 8i days (it's been many years), the only way to do this is to install the XML XDK. From http://www.oracle.com/technology/tech/xml/xdk/xdk_java.html, it says "The Oracle9i versions of the XDK can also be used to build applications designed to interface with Oracle8i databases." I had thought the 10g version could do that as well but I'm not seeing it now.
Since XMLType was not part of 8i, you will need to use PL/SQL to take your Select statement results and build them into a DOMDocument structure.
Hope that helps. -
Generating Deeply nested XML from a flat file
Hi All,
I am working on a MQ to IDOC scenario.
I am getting a flat file as input. I need to convert it into XML( so that XI can understand it).
But conversion is into a "Deeply Nested XML from a Flat File" at sender side (JMS Adapter).
Any inputs on this.
Regards,
VikasYou can only convert flat file into xml structure with 3 levels.
If you need to convert flat file into deep nested xml structure, you have to do java mapping or xslt or abap mapping. There is a tool, I think it's called conversion agent by itemfield (bought by SAP), which can do pretty everything with conversion. Never used it though.
Jayson -
Nested XML Output in PL/SQL
I need to generate XML that looks like this:
<Person>
<Name>
<FirstName>IMA</FirstName>
<MiddleName>ANOTHER</MiddleName>
<LastName>TEST</LastName>
<BirthDate>04/05/1982</BirthDate>
</Name>
<IDDetails>
<SSNID>234-23-3333</SSNID>
<OtherID>19781</OtherID>
</IDDetails>
<PhysicalDetails>
<Weight>145</Weight>
<EyeColor>BLUE</EyeColor>
<HairColor></HairColor>
<Sex>FEMALE</Sex>
<Race>BLACK</Race>
<SkinToneText></SkinTone>
</PhysicalDetails>
<SocialDetails>
<Ethnicity>UNKNOWN</Ethnicity>
<Language>ENGLISH</Language>
</SocialDetails>
<Address>
<Street>123 Somewhere Street</Street>
<City>AnyWhere</City>
<State>Confusion</State>
<Zip>99999</Zip>
</Address>
</Person>
I was able to sucessfully generate it in SQL by creating a view using this code:
create or replace view person_xml_view as
select
xmlelement("Person",
xmlelement("Name",
xmlelement("FirstName", first_name),
xmlelement("MiddleName",middle_name),
xmlelement("LastName",last_name),
xmlelement("BirthDate",to_char(date_of_birth,''MM/DD/YYYY''))),
xmlelement("IDDetails",
xmlelement("SSN",b.external_number),
xmlelement("OtherID",a.mni)),
xmlelement("PhysicalDetails",
xmlelement("Weight",a.weight),
xmlelement("EyeColor",a.eye_color),
xmlelement("HairColor",a.hair_color),
xmlelement("Sex",a.sex),
xmlelement("Race",a.race),
xmlelement("SkinTone",a.skin_tone)),
xmlelement("SocialDetails",
xmlelement("Ethnicity",ethnicity),
xmlelement("Language",language)),
xmlelement("Address",
xmlelement("Street",c.address),
xmlelement("City",c.city),
xmlelement("State",c.state),
xmlelement("Zip",c.zip)))
as result from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = 'SOCIAL SECURITY NUMBER') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= 'T') AND
a.MNI = 19781);
My end goal is to write a function that returns the XML back to the caller, but when I the dbms_xmlgen I can't get the sub-tags to be inserted correctly. Here's the code as it is today:
FUNCTION GETXML
( v_pk IN Number)
RETURN xmltype as out xmltype;
ctx dbms_xmlgen.ctxhandle;
BEGIN
ctx := dbms_xmlgen.newcontext('select a.first_name as "FirstName",
a.middle_name as "MiddleName",
a.last_name as "LastName",
to_char(a.date_of_birth,''MM/DD/YYYY'') AS "BirthDate",
b.external_number as "SSNID",
a.mni as "OtherID",
a.weight as "Weight",
a.eye_color as "EyeColor",
a.hair_color as "HairColor",
a.sex as "Sex",
a.race as "Race",
a.skin_tone as "SkinTone",
a.ethnicity as "Ethnicity",
a.language as "Language",
c.address as "Street",
c.city as "City",
c.state as "State",
c.zip as "Zip"
from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = ''SOCIAL SECURITY NUMBER'') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= ''T'') AND
a.MNI = '||V_MNI);
dbms_xmlgen.setrowsettag(ctx,'Person');
dbms_xmlgen.setrowtag(ctx,'Name');
dbms_xmlgen.setrowtag(ctx,'IDDetails');
dbms_xmlgen.setrowtag(ctx,'PhysicalDetails');
dbms_xmlgen.setrowtag(ctx,'SocialDetails');
dbms_xmlgen.setrowtag(ctx,'Address');
out := dbms_xmlgen.getxmltype(ctx);
dbms_xmlgen.closecontext(ctx);
return out;
END;
How do you do the nested tags?Hi,
Here is simple way of genrating nested XML.
FUNCTION GETXML
( v_pk IN Number)
RETURN sys.XMLType
CURSOR C1
IS
xmlelement("Person",
xmlelement("Name",
xmlforest(first_name as "FirstName",
middle_name as "MiddleName",
last_name as "LastName",
to_char(date_of_birth,''MM/DD/YYYY'') as"BirthDate"),
xmlelement("IDDetails",
xmlforest(b.external_number as "SSN",
a.mni as "OtherID")),
xmlelement("PhysicalDetails",
xmlforest(a.weight as "Weight",
a.eye_color as "EyeColor",
a.hair_color as "HairColor",
a.sex as "Sex",
a.race as "Race",
a.skin_tone as "SkinTone")),
xmlelement("SocialDetails",
xmlforest(ethnicity as "Ethnicity",
language as "Language")),
xmlelement("Address",
xmlforest(c.address as "Street",
c.city as "City",
c.state as "State",
c.zip as "Zip")) as result
from
names a,
numbers b,
addresses c
where
(a.mni = b.mni (+) AND
b.number_type (+) = 'SOCIAL SECURITY NUMBER') AND
(a.mni = c.mni (+) AND
c.current_address_flag (+)= 'T') AND
a.MNI = 19781);
v_xml sys.XMLType
BEGIN
open c1;
fetch c1 into v_xml;
close c1;
return v_xml;
END
In short use xmlforest to genrate inner child tags. -
Hi all, I could use some help (using version CS5.5).
I want to import (via Javascript) an XML file similar to this:
<movieRoot>
<dvds>
<movie>
<title>2001: A Space Odyssey</title>
<edition>Special Edition</edition>
<features>NOTHING</features>
<notes/>
</movie>
<movie>
<title>Airplane!</title>
<edition />
<features>Extra Laughs</features>
<notes/>
</movie>
</dvds>
</movieRoot>
I've been able to successfully do this, so no problem there.
Then I want to dump the child elements under the XML element "<dvds>" into a single text frame that spans 2 columns per page. That's easy enough too, except:
1) I want to filter the data so that empty elements or whose contents equal "NOTHING" do not appear.
2) I want to add static text title above some of the elements that remain (outside the XML proper).
3) Then I want to format the text (using Paragraph Styles).
Tall order, I know, but I'm keen on figuring it out. I initially created a document using placeholders and used the standard XML Import to populate it with data, which was filtered using scripts to remove extraneous placeholders and static text. It gave me the result I wanted, but as the XML will be regularly updated and since the "filtered" tags result in non-standard XML entries, it means starting over from scratch after every XML update. So I turned to scripting...
For point #1, I was able to filter properly using a recursive IF statement, tested here using message alerts:
I've included a bunch of variables for (hopefully) easier viewing.
var myXMLRoot = myDocument.xmlElements.item(0); //movieRoot
var myXMLParent = myXMLRoot.xmlElements.item(0); //dvds
var myXMLElement = myXMLParent.xmlElements.item(0); //movie
var currElement = myXMLElement.xmlElements.item(0); //title
for (i = 0; i < myXMLParent.xmlElements.length; i++)
myXMLElement = myXMLParent.xmlElements.item(i);
for (j = 0; j < myXMLElement.xmlElements.length; j++)
currElement = myXMLElement.xmlElements.item(j);
if (currElement.contents != "" && currElement.contents != "NOTHING")
alert (currElement.markupTag.name + ": " + currElement.contents);
It worked great until I tried to get it into an existing text frame. Since I want all the info in one text frame, placexml was out of the question, and markup worked but overwrote XML tags -- such as assigning the entire text frame to <movie/title> when I wanted it assigned to <dvds> with <movie/title> tags nested within it.
If you can help me with anything, this is really where I need pointed in the right direction most. But if you're feeling generous or bored...
Then for points #2 and #3, I want to take what's left ("filtered" XML data) and add additional text and formatting wherever certain tags are found.
For example, applying the paragraph style "MovieTitles" for any text within <title></title> XML tags; or adding the phrase "Special Features" (with paragraph style "Headers") above any text marked with <features> tags, while the content within those <features> tags applies the paragraph style "NormalText."
I've got some of this worked out in pieces already, but it generally falls apart because I can't get the tag structure correct in the text frame. I can provide more info as requested. Any help would be mighty appreciated!
UPDATE: Surprisingly, I've actually had some good success this evening on solving most of these problems. I'll post my results once I've finished up just in case anyone else can be helped by what I've learned.
One question remains for the moment: I've inserted text within an XML element, but outside of XML tags (e.g., </title>EDITION:<edition>) using "insertTextAsContent":
[xmlElementHere].insertTextAsContent("EDITION:", XMLElementPosition.beforeElement);
Does anyone know a good way to apply a paragraph style to that text without using a find & replace function later (after placing the XML into a text frame)?As posted into the other thread:
Yes, each record will be in its own frame.
You can use one of a couple solutions to stitch (link) each frame to the other, delete all but the first page and the first merged record, then resize that first merge frame and reflow the entire document.
https://forums.adobe.com/thread/1341730?start=0&tstart=0
Please review this thread. There is a couple posts with a script and you would want the last version of that script. You would have to follow the directions, as well as add a column at the beginning of your data and fill it with consecutive numbers.
Alternatively, there is a free plug-in by Rohiko for stitching merge data frames together, then follow the process above to reflow the document.
https://www.rorohiko.com/wordpress/indesign-downloads/textstitch/
Mike -
Correction for Nested XML Data Sample
I found an error in the sample code on the
Nested
XML Data Sample under "Using Nested Data Sets." Line 8 has
var dsToppings = new Spry.Data.NestedXMLDataSet(dsItems1,
"toppings");, but it should be
var dsToppings = new Spry.Data.NestedXMLDataSet(dsItems1,
"topping"); in order to match the XML file.
Another suggestion for us newbies would be to have the
samples start with a comment about any additional scripts we need
to insert into our files. It took me a long time to realize I
needed to include
<script type="text/javascript"
src="scripts/SpryNestedXMLDataSet.js"></script> with
the others in the head.
Thanks for your work!
JonathanHi Jonathan,
Thanks for catching that. I corrected the doc and the change
will appear when we release 1.5.
Also, regarding <script> includes sample, yes, we
should definitely be doing that.
Thanks!!!
--== Kin ==-- -
Database data to nested xml structure
Hi All,
I need to convert the data in the oracle database to nested xml tree structure as below:
Data in the database is in the following structure:
1 branch1 13-JAN-11 a.txt
1 branch1 25-JAN-11 b.txt
1 branch1 25-JAN-11 c.txt
1 branch2 20-JAN-11 d.txt
2
XML for the above data should be in the format:
<Root>
<Account_no value="1">
<Desc value="branch1">
<Date value="13-JAN-11">
<Name value="a.txt"/>
</Date>
<Date value="25-JAN-11">
<Name value="b.txt"/>
<Name value="c.txt"/>
</Date>
</Desc>
<Desc value="branch2">
<Date value="20-JAN-11">
<Name value="d.txt"/>
</Date>
</Desc>
</Account_no>
<Account_no value="2">
</Account_no>
</Root>
I am able to get this kind of xml structure using java after storing the database data in a n-ary tree. But it takes more time to execute.
Can this kind of same xml format be achieved using pl/sql programming?
Please help me with your valuable insights.
Thanks,
AlagappanHi,
Please always mention your db version (select * from v$version).
Here's one solution using SQL/XML functions :
Sample data used :
create table sample_data
account_no number,
description varchar2(30),
dt date,
name varchar2(30)
insert into sample_data values(1, 'branch1', to_date('13-JAN-11','DD-MON-RR'), 'a.txt');
insert into sample_data values(1, 'branch1', to_date('25-JAN-11','DD-MON-RR'), 'b.txt');
insert into sample_data values(1, 'branch1', to_date('25-JAN-11','DD-MON-RR'), 'c.txt');
insert into sample_data values(1, 'branch2', to_date('20-JAN-11','DD-MON-RR'), 'd.txt');
insert into sample_data values(2, 'branch3', to_date('20-JAN-11','DD-MON-RR'), 'e.txt');Query :
SELECT xmlserialize(document
xmlelement("Root",
xmlagg(
xmlelement("Account_no", xmlattributes(account_no as "value"),
xmlagg(
xmlelement("Desc", xmlattributes(description as "value"), dt)
order by description
) order by account_no
as clob indent ) doc
FROM (
SELECT account_no, description,
xmlagg(
xmlelement("Date", xmlattributes(to_char(dt,'DD-MON-RR') as "value"), name)
order by dt
) dt
FROM (
SELECT account_no, description, dt,
xmlagg(
xmlelement("Name", xmlattributes(name as "value"))
order by name
) name
FROM sample_data
GROUP BY account_no, description, dt
GROUP BY account_no, description
GROUP BY account_no
DOC
<Root>
<Account_no value="1">
<Desc value="branch1">
<Date value="13-JAN-11">
<Name value="a.txt"/>
</Date>
<Date value="25-JAN-11">
<Name value="b.txt"/>
<Name value="c.txt"/>
</Date>
</Desc>
<Desc value="branch2">
<Date value="20-JAN-11">
<Name value="d.txt"/>
</Date>
</Desc>
</Account_no>
<Account_no value="2">
<Desc value="branch3">
<Date value="20-JAN-11">
<Name value="e.txt"/>
</Date>
</Desc>
</Account_no>
</Root>
Here, I used XMLSerialize function with indent option to format the output (available starting with 11g). -
How do you use nested XML in InDesign such as DocBook upon import?
Something like:
<blockquote>
<para>Some text here</para>
<para>More text here</para>
</blockquote>
I know InDesign has the map tags to styles function... how could this sort of nesting be interpretted as styles though?
Would you map the blockquote element as [Not Mapped]... or as a character style? or what?
<para> Can't be a paragraph style since it is also used as the body text.
Would something like this have to be scripted to import correctly?There is not a good way to express concepts like <blockquote/> in InDesign's XML import.
I don't see anything here that is "nesting," though. Perhaps if you gave us the context?
If you have your other <para/>s in some other tag instead of <blockquote/> then they could all be paragraph styles. But if you have <para/>s at varying tree levels, you are really stuck. Transofrm it into some other kind of XML, or use scripting.
So, try giving us a lot more (5 times as much?) context and a clear explanation of what you want to do, but I think this is probably not a good approach. -
Generating nested XML with XSU
Hi,
I have been trying to generate a nested XML document with the
XSU Utility (Rdbms 9.0.1) by setting up an nested table (see below)
and the using the command line utiliy as:
c:\>java OracleXML getXML -user "scott/tiger" "SELECT * from dept_type_tab
The result is nested all right, but all texts seem to be in Hex representation:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPT>
<DNAME>0x5245534541524348</DNAME>
<EMP>
<ENAME>0x534D495448</ENAME>
</EMP>
</DEPT>
</ROW>
Can anyone point out to me, where I went wrong? ;-(
Thanx for any input
Jan-Peter
create type emp_type as object
ename varchar2(10)
create type dept_type as object
dname varchar2(14),
emp emp_type
create view tmp_jpm2 as
select dept_type(dept.dname,
emp_type(emp.ename)
) dept
from dept, emp WHERE (dept.deptno = emp.deptno);
create table dept_type_tab ( dept dept_type);
insert into dept_type_tab (dept) select dept from tmp_jpm2;Hi,
I have been trying to generate a nested XML document with the
XSU Utility (Rdbms 9.0.1) by setting up an nested table (see below)
and the using the command line utiliy as:
c:\>java OracleXML getXML -user "scott/tiger" "SELECT * from dept_type_tab
The result is nested all right, but all texts seem to be in Hex representation:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DEPT>
<DNAME>0x5245534541524348</DNAME>
<EMP>
<ENAME>0x534D495448</ENAME>
</EMP>
</DEPT>
</ROW>
Can anyone point out to me, where I went wrong? ;-(
Thanx for any input
Jan-Peter
create type emp_type as object
ename varchar2(10)
create type dept_type as object
dname varchar2(14),
emp emp_type
create view tmp_jpm2 as
select dept_type(dept.dname,
emp_type(emp.ename)
) dept
from dept, emp WHERE (dept.deptno = emp.deptno);
create table dept_type_tab ( dept dept_type);
insert into dept_type_tab (dept) select dept from tmp_jpm2; -
Producing nested xml with querying attributes from a nested table
How can one produce nested xml querying columns from a nested table? Looking at the object documentation, I can readily unnest the tables. Using your examples in the book, unnesting is select po.pono, ..., l.* from purchaseorder_objtab po, table (po.lineitemlist_ntab) l where l.quantity = 2;
what if I don't want to unnest and don't want a cursor. I would like to produce nested xml.Gail,
Although you can use XSU (XML-SQL Util) in 8.1.7, I would recommend that you upgrade to 9i for much better support (both in functionality and performance) of XML in the database. For example, in Oracle9i there are:
- a new datatype - XMLType for storing and retrieving XML documents
- DBMS_XMLGEN package and SYS_XMLGEN, SYS_XMLAGG functions for generating XML document from complex SQL queries
- A pipelined table function to break down large XML documents into rows.
You can check out some examples using SYS_XMLGEN and DBMS_XMLGEN for your specific needs at http://download-west.oracle.com/otndoc/oracle9i/901_doc/appdev.901/a88894/adx05xml.htm#1017141
Regards,
Geoff
Maybe you are looking for
-
Bex transaction to ECC/CRM screen
Hi We have a unique requirement of trigerring a ECC/CRM transaction screen from Bex report when the user clicks on context menu or a key field. Ex BP Number. We are using ECC 6.0 and CRM 5.0 Any sugesstion ideas on how to go about doing it. Thanks
-
I just upgraded to Ilife '08 and now I am unable to view my iPhoto library in Photoshop. I can see the "iPhoto" file, but it is 'greyed" out and not an option I can click on. I've looked all over trying to figure out what's wrong...I can open iPhoto
-
Updated itunes updated ipad 3 to ios7 did restart restore and now just have black screen
updated itunes updated ipad 3 to ios7 did restart restore and now just have black screen
-
Can't set up iPhone 6 from back up!! Please Help!!!
I just got my iphone and i tried to set it up from the back up from my old iphone but when i try to do this a message pops up saying the back up is corrupted or is not compatible with the new iphone. i don't know what to do!!! Is anyone having the sa
-
Is there a way to have one common keyword list which can be shared between multiple catalogues?