Formatting XML into VARCHAR2
Hi,
I am looking at an XML file/feed, and within it there are paragraphs and page breaks (<para>,
). When I'm extracting the data into a varchar2 field, i want to preserve the paragraph/break structure...
e.g.
SELECT text_col
FROM XMLTABLE('/'
PASSING (xmltype('<para>This is paragraph 1.<br/>This is p1, line 1.<br/>This is p1, line 2.</para>'))
COLUMNS text_col VARCHAR2(1000) PATH '/'
);gives
This is paragraph 1.This is p1, line 1.This is p1, line 2.What I'm after is:
This is paragraph 1.
This is p1, line 1.
This is p1, line 2.Is this achievable?
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit
Thanks.
Hi,
On 11g, I would use this :
SQL> select text
2 from xmltable(
3 'string-join(
4 for $i in /para/node()
5 return
6 typeswitch ($i)
7 case text() return string($i)
8 case element(br) return "&#xA;"
9 default return ""
10 , "")'
11 passing xmlparse(content '<para>Line1<br/>Line2<br/>Line3</para>')
12 columns text varchar2(2000) path '.'
13 )
14 ;
TEXT
Line1
Line2
Line3
but I'm not sure it works on your version. You can try though.
Another solution would be :
SQL> select utl_i18n.unescape_reference(replace(x.text.getstringval(), '<br/>', '&#xA;')) as text
2 from xmltable('/para'
3 passing xmltype('<para>Line1&Line1.1<br/>Line2<br/>Line3</para>')
4 columns text xmltype path 'node()'
5 ) x
6 ;
TEXT
Line1&Line1.1
Line2
Line3
Similar Messages
-
OWB11gR2 - simple and easy way to load XML formatted data into db tables?
Hi,
we're currently trying to load table data stored in XML files into our datawarehouse using OWB 11gR2.
However, we're finding this is not quite as trivial as loading flat files...
Most postings on this forum points to the blog-entry title "Leveraging XDB" found here (http://blogs.oracle.com/warehousebuilder/2007/09/leveraging_xdb.html).
This blog also references the zip-file owb_xml_etl_utils.zip, which seems to have disappeared from it's original location and can now be found on sourceforge.
Anyway, the solution described is for OWB 10g, and when trying to import experts from the zip-file etc. we end up not being able to run the "Create ETL from XSD" expert, as the 11gR2 client is different from the 10g and does not have the Experts menu et.al.
Also, this solution was published over 3 years ago, and it seems rather strange that importing XML-formatted data should still be so cumbersome in the newer warehouse builder releases.
The OWB 11gR2 documentation is very sparse (or rather - quite empty) on how to load XML data, all it has is a few lines on "XML Transformations", giving no clue as to how one goes about loading data.
Is this really the state of things? Or are we missing some vital information here?
We'd have thought that with 11g-releases, loading XML-data would be rather simple, quick and painless?
Is there somewhere besides the blog mentioned above where we can find simple and to the point guidelines for OWB 11gR2 on how to load XML-formatted data into Oracle tables?
Regards,
-Haakon-Yes it is possible to use SQL*Loader to parse and load XML, but that is not what it was designed for and so is not recommended. You also don't need to register a schema, just to load/store/parse XML in the DB either.
So where does that leave you?
Some options
{thread:id=410714} (see page 2)
{thread:id=1090681}
{thread:id=1070213}
Those talk some about storage options and reading in XML from disk and parsing XML. They should also give you options to consider. Without knowing more about your requirements for the effort, it is difficult to give specific advice. Maybe your 7-8 tables don't exist and so using Object Relational Storage for the XML would be the best solution as you can query/update tables that Oracle creates based off the schema associated to the XML. Maybe an External Table definition works better for reading the XML into the system because this process will happen just once. Maybe using WebDAV makes more sense for loading XML to be parsed (I don't have much experience with this, just know it is possible from what I've read on the forums). Also, your version makes a difference as you have different options available depending upon the version of Oracle.
Hope all that helps as a starter.
Edited by: A_Non on Jul 8, 2010 4:31 PM
A great example, see the answers by mdrake in {thread:id=1096784} -
How to format a not well formed xml into well formed
Hi,
Here's what I'm trying to do: I have a build a report based on query results. In the query result, one field is a CLOB (which contains XML. The XML contains two tags - "description" and "count"). I want to read (&parse) the XML and store the "description" and "count" in a hashmap. But when I try to parse it, I end up in an error. I'm currently using XmlParse but I got an error "The markup following the root element should be well formed." I immediately used IsXml() to find out if the XML I am reading is well formed. And the answer is "NO".
Could someone help me in converting it into a "well formed" one?
(This is what I've tried: I appended "<?xml version="1.0" encoding="UTF-8"?>" to the XML I'm reading coz it was missing this. I later used XmlFormat to convert the XML into a string format. But IsXML tells me that even this is not well formed.)
Thanks much for your help!XML encodes information is a specific way. Well-formedness determines whether or not a string is an XML document in the first place.
However, as well-formedness can be broken by any arbitrary number of factors, it is in general impossible to automate the repair process to recover a well-formed XML document. You have to do it manually, using an XML or a text editor. -
I have an oracle table i have to export as formatted xml
I really want the data to look like this : (and need to get rid of the cdata)
<?xml version='1.0' ? XML_DATE = "2012-06-26 08:12:09 PM">
<APPLICATION NAME = "XMLTESTING">
<WEBPAGE>
<PROJECT>
<column1>ABC</column1>
<column2>DEF</column2>
<column3>GHI</column3>
<column4>JKL</column4>
<column5>MNO</column5>
</PROJECT>
<PROJECT>
<column1>ABG</column1>
<column2>DRF</column2>
<column3>GLY</column3>
<column4>JAL</column4>
<column5>MPO</column5>
</PROJECT>
<PROJECT>
<column1>BBC</column1>
<column2>GEF</column2>
<column3>LHI</column3>
<column4>JCL</column4>
<column5>MWO</column5>
</PROJECT>
</WEBPAGE>
</APPLICATION>
create table "XML_TESTING" (
"column1" varchar2(50byte),
"column2" varchar2(50byte),
"column3" varchar2(50byte),
"column4" varchar2(50byte),
"column5" varchar2(50byte)
INSERT into XML_TESTING values ('ABC','DEF','GHI','JKL','MNO');
INSERT into XML_TESTING values ('ABG','DRF','GLY','JAL','MPO');
INSERT into XML_TESTING values ('BBC','GEF','LHI','JCL','MWO');
CREATE TABLE xml_cl(result CLOB);
DECLARE
ctxqry DBMS_XMLGEN.ctxHandle;
result CLOB;
BEGIN
ctxqry := dbms_xmlgen.newContext('SELECT * FROM xml_testing');
DBMS_XMLGEN.setRowTag(ctxqry,'APPLICATIO NAME = "XML TESTING"');
--DBMS_XMLGEN.setMaxRows(ctxqry,5);
DBMS_XMLGEN.setrowsettag(ctxqry,'WEBPAGE');
LOOP
result := DBMS_XMLGEN.getXML(ctxqry);
EXIT WHEN
DBMS_XMLGEN.getNumRowsProcessed(ctxqry)=0;
INSERT INTO xml_cl VALUES(result);
END LOOP;
END;
SELECT * FROM xml_cl
THEN I EXPORT TO XML FROM HERE.
this is how xml currently looks
<?xml version='1.0' encoding='Cp1252' ?>
<RESULTS>
<ROW>
<COLUMN NAME="RESULT"><![CDATA[<?xml version="1.0"?>
<WEBPAGE>
<APPLICATIO_x0020_NAME_x0020__x003D__x0020__x0022_XML_x0020_TESTING_x0022_>
<column1>ABC</column1>
<column2>DEF</column2>
<column3>GHI</column3>
<column4>JKL</column4>
<column5>MNO</column5>
</APPLICATIO_x0020_NAME_x0020__x003D__x0020__x0022_XML_x0020_TESTING_x0022_>
<APPLICATIO_x0020_NAME_x0020__x003D__x0020__x0022_XML_x0020_TESTING_x0022_>
<column1>ABG</column1>
<column2>DRF</column2>
<column3>GLY</column3>
<column4>JAL</column4>
<column5>MPO</column5>
</APPLICATIO_x0020_NAME_x0020__x003D__x0020__x0022_XML_x0020_TESTING_x0022_>
<APPLICATIO_x0020_NAME_x0020__x003D__x0020__x0022_XML_x0020_TESTING_x0022_>
<column1>BBC</column1>
<column2>GEF</column2>
<column3>LHI</column3>
<column4>JCL</column4>
<column5>MWO</column5>
</APPLICATIO_x0020_NAME_x0020__x003D__x0020__x0022_XML_x0020_TESTING_x0022_>
</WEBPAGE>
]]></COLUMN>
</ROW>
</RESULTS>
hope someone can help.
did alot of searching and reading and just cant find an answer
thank youUse SQL/XML functions to build and serialize the document as CLOB in a single query :
SQL> SELECT XMLSerialize(document
2 XMLElement("APPLICATION",
3 XMLAttributes('XMLTESTING' as "NAME")
4 , XMLElement("WEBPAGE",
5 XMLAgg(
6 XMLElement("PROJECT",
7 XMLForest("column1", "column2", "column3", "column4", "column5")
8 )
9 )
10 )
11 )
12 as clob
13 indent --< for formatting purpose only
14 )
15 FROM xml_testing
16 ;
XMLSERIALIZE(DOCUMENTXMLELEMEN
<APPLICATION NAME="XMLTESTING">
<WEBPAGE>
<PROJECT>
<column1>ABC</column1>
<column2>DEF</column2>
<column3>GHI</column3>
<column4>JKL</column4>
<column5>MNO</column5>
</PROJECT>
<PROJECT>
<column1>ABG</column1>
<column2>DRF</column2>
<column3>GLY</column3>
<column4>JAL</column4>
<column5>MPO</column5>
</PROJECT>
<PROJECT>
<column1>BBC</column1>
<column2>GEF</column2>
<column3>LHI</column3>
<column4>JCL</column4>
<column5>MWO</column5>
</PROJECT>
</WEBPAGE>
</APPLICATION>
Then you can call DBMS_XSLPROCESSOR.CLOB2FILE to write the CLOB to a file, no need of an intermediate table. -
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'); -
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 -
Using a CWM format XML as datastore; COM SDK to read the file and create Universe
Hello everyone
We are in the process of migrating from a metadata store to BusinessObjects Universe and the plan is to use Java/COM SDK to accomplish that. We have run into limitations with both the SDKs. Java SDK doesn't provide that facility and using COM SDK we are trying to read from a XML file (metadata in CWM format) and create the universe but so far haven't been successful. If the (Universe)Designer can read a CWM format xml file (say created from BODS) we are wondering why can't a customer made COM program do the same.
Has anyone attempted this and been successful. Please acknowledge.
ThanksI have written C#.NET code to build universes on the fly using the Designer SDK with no problems. However, I wasn't using CWM formatted data to do this.
I have two suggestions for you:
1. Since not all of the functionality in the Designer tool seems to be available through the SDK, can you parse the CWM xml file in your code and build the universe based on the data instead of trying have Designer build it?
2. Since you're using Java, you may get better answers by posting this question in the Java SDK Application Development space here: http://scn.sap.com/community/bi-platform/java-sdk
-Dell -
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 -
EXCEL XML into XML - using MessageMapping
Hi
I have an XSLT that I use to convert an Excel XML into another XML format.
But I wonder if there a way to do this via the XI Message Mapping instead?. I have tried but I am stuck at the moment trying to identify particular rows. For instance I need to fill the <desc> tag from the 3rd Cell.
[code]
Original Excel data
Cell1 Cell2 Cell3 Cell4 Cell5
Row1 | AY02 403KITA Concentrator Kit $91.00 22-01-2005
Row2 | AY02 401KITC Oxygen Reg/Flow $65.00 08-09-2006
[/code]
Input Source file (a cut down version...)
[code]
<Workbook>
<Worksheet>
<Table>
<Row>
<Cell>
<Data>AY02</Data>
</Cell>
<Cell>
<Data>403KITA</Data>
</Cell>
<Cell>
<Data>Concentrator Kit</Data>
</Cell>
<Cell>
<Data>$91.00</Data>
</Cell>
<Cell>
<Data>22-01-2005</Data>
</Cell>
</Row>
<Row>
<Cell>
<Data>AY02</Data>
</Cell>
<Cell>
<Data>401KITC</Data>
</Cell>
<Cell>
<Data>Oxygen Reg/Flow Portable</Data>
</Cell>
<Cell>
<Data>$65.00</Data>
</Cell>
<Cell>
<Data>08-09-2006</Data>
</Cell>
</Row>
</Table>
</Worksheet>
</Workbook>
[/code]
Target XML
[code]
<Batch>
<items>
<item>
<catlgItemNum>403KITA</catlgItemNum>
<desc>Concentrator Kit</desc>
<unitPrice>$91.00</unitPrice>
</item>
<item>
<catlgItemNum>401KITC</catlgItemNum>
<desc>Oxygen Reg/Flow Portable</desc>
<unitPrice>$65.00</unitPrice>
</item>
</items>
</Batch>
[/code]Hi Peter,
Please create the following user-defined function (cache: context):
public static void getIndexedValue(
String[] a,
String[] b,
ResultList result,
Container container) {
//write your code here
Integer iB = new Integer(b[0]);
result.addValue(a[iB.intValue()]);
You can then set up the following mappings:
Row - item
Data (context Row)
getIndexedValue - ...
Constant [1, 2, 3] /
Best regards
Joachim -
How to change Un formatted XML to Formatted XML in SSRS ?
Hi Friends,
I have an issue with SSRS report when exporting it into xml , it's showing un formatted xml like below
but my requirement is it has to show formatted xml like below
Please help me with this issue,
NOTE: here i am building reports on Cube.
Thanks in advance.
NaveenHi NaveenMSBI,
By default, the XML rendering extension does not display formatted textbox values. In this case, we can use the UseFormattedValue device information setting to make the XML rendering extension display textbox values formatted the same way they are formatted
in report viewer or report designer preview. When UseFormattedValue is set to true, the formatted value is used instead.
You can specify UseFormattedValue directly on the URL against the ReportServer endpoint or in a SOAP request. This can also be configured as the default for all XML rendering extension by editing the RSReportServer.config file.
For the details, please refer to the links as follows:
Passing Device Information Settings to Rendering Extensions
XML Device Information Settings
Hope this helps.
Regards,
Heidi Duan
Heidi Duan
TechNet Community Support -
Convert MBox into XML into Java Objects
Hello all,
this is a general question, i dont know weather there is such libs or not.
However, please tell me what you know.
i want to program a java application for searching purpose in Mbox.
i thought its possible and easier to try to convert the emails from the MBox into XML files, and from these create java objects when i need or even convert the XML into html for viewing.
Any suggestions are welcome.
Also antoher solutions are greate.
thanks in advance!
Sako.I don't know what this MBox you speak of is - I assume it's not the thing I use to hook upa guitar to GarageBand. Maybe you mean it as a generic term for mailbox? The easiest solution (to my mind) would be to use a Java API provided by whatever MBox is. If there is no such thing, then if you get XML-formatted version of the messages I suppose writing code to parse the XML into Java Objects would be a good option if you wanted to do further manipulation of them, but if all you want to do is display them as HTML in a browser then just use XSLT to transform them.
Good Luck
Lee -
Extract part of xml into CLOB or XMLType
I need to extract part of XML into CLOB or some another type. But I don't need only extract data, by whole part od xml with elements. How could I do it in PL/SQL?
For example from this xml:
<bookstore>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
I need to get:
"<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>"
THXThat's why I need to process every book alone - to know which authors belongs to single book.For that specific requirement, a single query would do.
Assuming variable "v_xml_clob" holds the XML document :
<bookstore>
<name>nameOfBookstore</name>
<address>1st Avenue 24, SF</address>
<book category="COOKING">
<title lang="en">Everyday Italian</title>
<author>
<name>Giada De Laurentiis</name>
<birth>1956</birth>
</author>
<author>
<name>xxx</name>
<birth>1955</birth>
</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>
<name>Rowning</name>
<birth>1977</birth>
</author>
<author>
<name>xxx</name>
<birth>1955</birth>
</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>You can do :
SELECT *
FROM XMLTable(
'for $i in distinct-values($d//book/author/name)
where count($d//book/author[name=$i]) = 1
return $i'
passing xmltype(v_xml_clob) as "d"
columns author_name varchar2(80) path '.'
AUTHOR_NAME
Rowning
Giada De Laurentiis -
XML into CLOB, corrupt text (Cyrillic charset, utf-8)
Hello, everyone!
We use Oracle ESB 10.1.3.5. We have problem with encoding/decoding(?) Cyrillic charset when putting xml-formatted data into CLOB. Here some details:
The FTP-adapter reads an XML-file (UTF-8) and transfers to RS-service. RS-service invokes the DB-adapter, which calls stored procedure in Oracle DB 10.2.0.4.(NLS_CHARACTERSET:CL8MSWIN1251) Procedure has one input parameter with type CLOB. Procedure does an insert into the table with a column of type CLOB. We wish to receive entire XML from initial file in a corresponding field of the table.
It works, except corrupted Cyrillic characters (mostly replaced with "?" symbols).
From ESB log we can see that db-adapter receive uncorrupted payload. We test to upload xml-file without ESB, using the same stored procedure, and the characters were introduced correctly.
Maybe someone faced with something like that, or have a thoughts, to solve this problem. Please help!Hi,
I've got solution from support:
1)Add parameter -Dfile.encoding=UTF-8 in opmn.xml in the ESB container in JVM options:<process-type id="oc4j_soa" module-id="OC4J" status="enabled"> <module-data> <category id="start-parameters"> <data id="java-options" ... -Dfile.encoding=UTF-8"/> ...{quote}
2)opmnctl stopall;
3)opmnctl startall.
Thank You All. -
How to import XML into SQL Table
Dear all,
There are a lot of books about exporting data into XML format.
Actually, how to use XML Documents? Sorry I am new that I ask such a question.
What i think may be exchange or save data using xml. If so, How to import into MS SQL table? Do it need to do any mapping?
Appreciate for your hintsAre 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 -
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>
Maybe you are looking for
-
I have the Bravia and all was well. I have a sony tuner and the blue ray and cable/tivo and mac mini were all plugged into the tuner and the tuner into an HDMI port. then i got apple tv. I plugged it in to a separate HDMI port and i got a strange s
-
I have a iPhone 4 and all of a sudden when I answer a phone call the person on the other end can't hear me ???? I can hear them , so I've had to put it on speaker for all my calls - ? Any tips on how to get it back to being able to speak normally
-
Upgraded to Snow Leopard and now CS2 wont launch
I've just installed Mav OS X Snow Leopard on my ancient MacBook and now my very old photoshop CS2 wont launch - it was working fine before I upgraded my operating system. Help!
-
To download a list output to excel sheet
Hi All, I am running the transaction MD47 for Product Group Planning. I get a list output with as many as 90 columns. When I try to download the output into an excel (System > List > Save > Local File ) only the columns which appear on the screen are
-
Change paragraph style from X to Y in Pages Doc
Hi Sorry for such a simple question, but I have looked through the Applescript manual and searched this forum and can't find a solution to my problem. All I want to do is loop through the paragraphs of a Pages document and if the paragraph style is "