XSLT dynamic XML data serverSide. NO External XML file
I am developing a web application currently using Tomcat 3.2.4, latest Xereces and Xalan.
I have a JSP page that 1st includes a HTML menu, I then wish to include a JSP page that will produce XML data. I would like to apply an XSLT to this XML data serverSide.. All of the solutions I have seen to date refer to a static XML file.. whereas the data in my XML structure is dynamic..
If anyone could please lend a hand it would be greatly appretiated.
Evan.
Sample code for transforming xmlstring
public String transformXML(String xmlString, String screenName) {
Document document;
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
StringWriter stw = new StringWriter();
try {
//File stylesheet = new File(uc.getXSLName(screenName));
File stylesheet = null;
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(new InputSource(new StringReader(xmlString)));
StreamSource stylesource = new StreamSource(stylesheet);
StreamResult result = new StreamResult(stw);
result.setWriter(stw);
DOMSource source = new DOMSource(document);
// Use a Transformer for output
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(stylesource);
transformer.transform(source, result);
return stw.toString();
catch (Exception e) {
System.out.println(e);
return null;
}
Similar Messages
-
Loading new xml data into a already xml populated image display
Hi everybody,
I have a question about loading new xml data into a already xml populated image gallery.
So I have my gallery set up so it calls some xml when it first loads. What I would now like to do is load different sets of images via a different xml sheet via the click of a button.
So for example the loaded gallery already has all thumbs loaded and user can click on them to view the full size image. So next instead of the user having to close this gallery to allow a new gallery to open with a different set of pictures I would just like to have a button. This button will unload the existing thumbs from the gallery and load in new ones from a different xml file.
If anybody can help me with this it would be great as I am still on a steep learning curve with AS3.
Here is my AS3
var xmlPath:String = "pictures.xml";
var xml:XML;
var loader = new URLLoader();
loader.load(new URLRequest(xmlPath));
loader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(e:Event):void
if ((e.target as URLLoader) != null )
xml = new XML(loader.data);
createMenu();
var numberOfItems:uint = 0;
var menuItems:Array = new Array();
function createMenu():void
numberOfItems = xml.items.item.length();
var count:uint = 0;
for each (var item:XML in xml.items.item)
var imageLoader=new Loader();
var menuItem:MenuItem = new MenuItem();
menuItem.addChild(imageLoader);
imageLoader.load(new URLRequest(item.url));
menuItem.linkTo = item.linkTo;
menuItem.mouseChildren = false;
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
menuItems.push(menuItem);
addChild(menuItem);
count++;
function ***():void
//menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
for (var i:uint = 0; i < menuItems.length; i++)
setChildIndex(menuItems[i], i);Thanks so much for the reply Andrei1
I think maybe my lack of knowledge when it comes to AS3 is not helping me at the moment because I thought I understood the code you supplied but there is something not going quite right.
So I messed around with the code and added the new_loaded_thumbs_btn to load in the "new_pictures.xml" but I am def doing something wrong.
import flash.ui.ContextMenuItem;
var xmlPath:String = "pictures.xml";
var xml:XML;
var numberOfItems:uint = 0;
var menuItems:Array = new Array();
var loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, xmlLoaded);
loadXML("pictures.xml");
new_loaded_thumbs_btn.addEventListener(MouseEvent.CLICK, loadXML);
function loadXML(path:String):void {
loader.load(new URLRequest("new_pictures.xml"));
function loadXML(path:String):void {
loader.load(new URLRequest(path));
function xmlLoaded(e:Event):void
xml = new XML(loader.data);
createMenu();
function createMenu():void
clearMenu();
numberOfItems = xml.items.item.length();
var count:uint = 0;
var imageLoader;
var menuItem:MenuItem;
for each (var item:XML in xml.items.item)
imageLoader = Loader();
menuItem = new MenuItem();
menuItem.addChild(imageLoader);
imageLoader.load(new URLRequest(item.url));
menuItem.linkTo = item.linkTo;
menuItem.mouseChildren = false;
menuItem.addEventListener(MouseEvent.CLICK, itemClicked);
menuItems.push(menuItem);
addChild(menuItem);
count++;
sortChildren();
// removes previously placed objects
function clearMenu():void {
var menuItem:MenuItem;
while (menuItems.length > 0) {
menuItem = menuItems[0];
removeChildAt(getChildIndex(menuItem));
menuItem.shift();
function sortChildren():void
//menuItems.sortOn("zpos3D", Array.NUMERIC | Array.DESCENDING);
for (var i:uint = 0; i < menuItems.length; i++)
setChildIndex(menuItems[i], i);
When the image display 1st loads it displays the new_pictures.xml thumbs which I thought would load through my new button when clicked.
And there was me thinking I was getting the hang of AS3.
Could you please point me in the right direction in what I am doing wrong,
Thanks for your time and effort in advance -
XML data (Output) into a flat file
I need to convert XML data into a flat file, which is having "|" as delimiter and ftp the same to a server. The XML data is an output of BPEL activity. The XML data is employee records. Each employee records should come as one line in the flat file.
Is it possible to do this? if so, what will be the steps
ThanksHi,
You need to use file adapter to write your XML payload as a flat file.
Following are the steps to write XML payload into a flat file:
1. Create a sample flat file and add few rows in which fields should be delimited with pipe symbol. See the record sample given below:
Name|Age|Address|City|State|Zip
Sam|32|2788 Viking Dr|Green Bay|WI|54304
Here first row is the header row, you can remove the header row if it is not required.
2. Create a file adapter service using adapter configuration wizard. Give file name and folder location where you want to write flat file. On step 5 of the adapter configuration wizard you have to define or select message schema. Click on Define Schema for Native Format button, then Native Format Builder Wizard will be opened, here you can define message schema for your flat file.
2.1 Here you need to select Delimited for file type.
2.2 Give details about your flat file, select your sample flat file here, which you have created in step 1 above.
2.3 Click Next button twice and go to step 4, here give namespace and element names you want and click on Next.
2.4 In step 5 you need to specify delimiters. Wizard doesn’t shows *|* as a delimiter so you need to enter *|* in the Delimited By combo box and click on Next button.
2.5 Complete remaining steps and click on Finish in the wizard.
3. Finish "Adapter Creation Wizard". Add BPEL activities (assign, invoke) to pass XML payload to file adapter and file adapter will generate *|* delimited flat file and write it to the given folder.
See the following article for more details on Native Format Builder Wizard:
http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/nfb.htm#CCHCIGCA
Regards,
Dharmendra
http://soa-howto.blogspot.com -
Problem inserting and querying XML data with a recursive XML schema
Hello,
I'm facing a problem with querying XML data that is valid against a recursive XML Schema. I have got a table category that stores data as binary XML using Oracle 11g Rel 2 on Windows XP. The XML Schema is the following:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="bold_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="keyword_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
<xs:element name="plain_text" type="xs:string"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="emph_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="text_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="parlist_type">
<xs:sequence>
<xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="listitem_type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="parlist" type="parlist_type"/>
<xs:element name="text" type="text_type"/>
</xs:choice>
</xs:complexType>
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element name="name"/>
<xs:element name="description">
<xs:complexType>
<xs:choice>
<xs:element name="text" type="text_type"/>
<xs:element name="parlist" type="parlist_type"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id"/>
</xs:complexType>
</xs:element>
</xs:schema>I registered this schema and created the category table. Then I inserted a new row using the code below:
insert into category_a values
(XMlElement("category",
xmlattributes('categoryAAA' as "id"),
xmlforest ('ma categ' as "name"),
(xmlelement("description", (xmlelement("text", 'find doors blest now whiles favours carriage tailor spacious senses defect threat ope willow please exeunt truest assembly <keyword> staring travels <bold> balthasar parts attach </bold> enshelter two <emph> inconsiderate ways preventions </emph> preventions clasps better affections comes perish </keyword> lucretia permit street full meddle yond general nature whipp <emph> lowness </emph> grievous pedro')))
The row is successfully inserted as witnessed by the results of row counting. However, I cannot extract data from the table. First, I tried using SqlPlus* which hangs up and quits after a while. I then tried to use SQL Developer, but haven't got any result. Here follow some examples of queries and their results in SQL Developer:
Query 1
select * from category
Result : the whole row is returned
Query 2
select xmlquery('$p/category/description' passing object_value as "p" returning content) from category
Result: "SYS.XMLTYPE"
now I tried to fully respect the nested structure of description element in order to extract the text portion of <bold> using this query
Query 3
select xmlquery('$p/category/description/text/keyword/bold/text()' passing object_value as "p" returning content) from category_a
Result: null
and also tried to extract the text portion of element <text> using this query
Query 4
select xmlquery('$p/category/description/text/text()' passing object_value as "p" returning content) from category_a
Result: "SYS.XMLTYPE".
On the other hand, I noticed, from the result of query 1, that the opening tags of elements keyword and bold are encoded as the less than operator "<". This explains why query 3 returns NULL. However, query 4 should display the text content of <text>, which is not the case.
My questions are about
1. How to properly insert the XML data while preserving the tags (especially the opening tag).
2. How to display the data (the text portion of the main Element or of the nested elements).
The problem about question 1 is that it is quite unfeasible to write a unique insert statement because the structure of <description> is recursive. In other words, if the structure of <description> was not recursive, it would be possible to embed the elements using the xmlelement function during the insertion.
In fact, I need to insert the content of <description> from a source table (called category_a) into a target table (+category_b+) automatically .
I filled category_a using the Saxloader utility from an flat XML file that I have generated from a benchmark. The content of <description> is different from one row to another but it is always valid with regards to the XML Schema. The data is properly inserted as witnessed by the "select * from category_a" instruction (500 row inserted). Besides, the opening tags of the nested elements under <description> are preserved (no "<"). Then I wrote a PL/SQL procedure in which a cursor extracts the category id and category name into varchar2 variables and description into an XMLtype variable from category_a. When I try to insert the values into a category_b, I get the follwing error:
LSX-00213: only 0 occurrences of particle "text", minimum is 1which tells that the <text> element is absent (actually it is present in the source table).
So, my third question is why are not the tags recognized during the insertion?
Can anyone help please?Hello,
indded, I was using an old version of Sqlplus* (8.0.60.0.0) because I had a previous installation (oracle 10g XE). Instead, I used the Sqlplus* shipped with the 11g2database (version 11.2.0.1.0). All the queries that I wrote work fine and display the data correctly.
I also used the XMLSERIALIZE function and can now display the description content in SQL Developer.
Thank you very much.
To answer your question Marco, I registered the XML Schema using the following code
declare
doc varchar2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="bold_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="keyword_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
<xs:element name="plain_text" type="xs:string"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="emph_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="text_type" mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="bold" type="bold_type"/>
<xs:element name="keyword" type="keyword_type"/>
<xs:element name="emph" type="emph_type"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="parlist_type">
<xs:sequence>
<xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="listitem_type">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="parlist" type="parlist_type"/>
<xs:element name="text" type="text_type"/>
</xs:choice>
</xs:complexType>
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element name="name"/>
<xs:element name="description">
<xs:complexType>
<xs:choice>
<xs:element name="text" type="text_type"/>
<xs:element name="parlist" type="parlist_type"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id"/>
</xs:complexType>
</xs:element>
</xs:schema>';
begin
dbms_xmlschema.registerSchema('/xmldb/category_auction.xsd', doc, LOCAL => FALSE,
GENTYPES => FALSE, GENBEAN => FALSE, GENTABLES => FALSE,
FORCE => FALSE,
OPTIONS => DBMS_XMLSCHEMA.REGISTER_BINARYXML,
OWNER => USER);
end;then, I created the Category table as follows:
CREATE TABLE category_a of XMLType XMLTYPE store AS BINARY XML
XMLSCHEMA "xmldb/category_auction.xsd" ELEMENT "category";Now, there still remains a problem of how to insert the "description" content which I serialized as a CLOB data into another table as XML. To this purpose, I wrote a view over the Category_a table as follows:
CREATE OR REPLACE FORCE VIEW "AUCTION_XWH"."CATEGORY_V" ("CATEGORY_ID", "CNAME", "DESCRIPTION") AS
select category_v."CATEGORY_ID",category_v."CNAME",
XMLSerialize(content ( xmlquery('$p/category/description/*' passing object_value as "p" returning content)) as clob) as "DESCRIPTION"
from auction.category_a p,
xmltable ('$a/category' passing p.Object_Value as "a"
columns category_id varchar2(15) path '@id',
cname varchar2(20) path 'name') category_v;Then, I wrote a procedure to insert data into the Category_xwh table (the source and target tables are slightly different: the common elements are just copied wereas new elements are created in the target table). The code of the procedure is the following:
create or replace PROCEDURE I_CATEGORY AS
v_cname VARCHAR2(30);
v_description clob ;
v_category_id VARCHAR2(15);
cursor mycursor is select category_id, cname, description from category_v;
BEGIN
open mycursor;
loop
/*retrieving the columns*/
fetch mycursor into v_category_id, v_cname, v_description ;
exit when mycursor%notfound;
insert into category_xwh values
(XMlElement("category",
xmlattributes(v_category_id as "category_id"),
xmlelement("Hierarchies", xmlelement("ObjHierarchy", xmlelement ("H_Cat"),
xmlelement ("Rollsup",
(xmlelement("all_categories",
xmlattributes('allcategories' as "all_category_id")))
xmlforest (
v_cname as "cat_name",
v_description as "description")
end loop;
commit;
close mycursor;
END I_CATEGORY;When I execute the procedure, I get the following error:
LSX-00201: contents of "description" should be elements onlyso, I just wonder if this is because v_description is considered as plain text and not as XML text, even if its content is XML. Do I need to use a special function to cast the CLOB as XML?
Thanks for your help.
Doulkifli -
Java input xml data and xsl template -output file excel
i need help or same special link on web.
i must develop code or use a special tool that make this.
INPUT:
xml that contain real data
xsl that explain a report template
OUTPUT:
file excel that show the template xsl with xml data source
thank for help me.Hi,
Please refer to "Oracle XML Publisher User's Guide".
Applications Releases 11i and 12
http://www.oracle.com/technetwork/indexes/documentation/index.html
This is also explained in the document attached in (Publishing Concurrent Requests with XML Publisher [ID 295409.1]).
Thanks,
Hussein -
Format XML data when writing to a file
Hi,
I am trying to write runtime data (XML) to a file. I am doign the following to write to the file:
public void saveFile() throws Exception {
try {
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
DOMSource source = new DOMSource(doc);
OutputStream output = new FileOutputStream(XMLFile);
StreamResult result = new StreamResult();
transformer.transform(source, result);
output.flush();
output.close();
} catch (Exception x) {
throw x;
The output from the above code is a clutter of elements. All the elements are on the same line some times.
1) How can I format the output? (Indent the elements in the file)
Is there a way to achieve this?
Sometimes, I see a square character at the end of some lines. I thought the output file is corrupt because of this character. But it does not seem to be a problem.
2) How do I avoid this character?Also, I am planning on using xpath in conjunction with DOM. However I read on one of the websites not to use too many xpath queries. I am using jdk 1.5.
Is it tight. My code might have to be run many times. Is the following ok?
or should I eliminate xpath and do my own traversing. I am concerned about runtime performance if I have to continue to update the xml file frequently.
public Element getMatchingNode(MyAttributes attr) throws Exception {
try {
File myFile = new File(XMLFile);
if (myFile.exists()) {
System.out.println(XMLFile + " File exists");
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
InputSource inputSource =
new InputSource(new FileInputStream(myFile));
String matchingString = this.getMatchingString(attr);
Element module =
(Element)xPath.evaluate("/" + TEST_TAG +
"/" +
TEST_TAG2 +
"/" +
DETAIL +
matchingString,
inputSource,
XPathConstants.NODE);
return module;
} else
return null;
} catch (Exception x) {
throw x;
private String getMatchingString(MyAttributes attrs){
StringBuffer buffer = new StringBuffer();
for (Enumeration e=attrs.keys(); e.hasMoreElements();){
String attribute = (String)e.nextElement();
String value = attrs.get(attribute);
buffer.append("[@" + attribute + "=" + "'" + value + "']");
return buffer.toString();
} -
Can an xml node load an external htm file?
I wanted to know if i could have an xml node load in an
external html page
src="filefolder/@nodename" works with an image tag, but how
would I accomplish this with a <div> and an html file
I tried
<div id="main" spry:detailregion="myviewer">
<div>{@caption}</div>
<div>{@fullimage}</div>
<div>{filefolder/@nodename}</div> though get
nothing because there is no src.
</div>
I have another strategy to use if not. However, it would be
sweet if I could.Hello,
I'm not sure this will work but you can give it a try to the
following code based on the
update
content sample:
<div id="main" spry:detailregion="myviewer">
<div>{@caption}</div>
<div>{@fullimage}</div>
<div id="nodename"></div> though get nothing
because there is no src.
<script type="text/javascript">
var element = document.getElementById('nodename');
Spry.Utils.updateContent(element, '{filefolder/@nodename}');
</div>
Please note that any CSS and JS code within the loaded
content will not execute correctly if you won't add the code in the
current file instead of the loaded file. Also please make sure that
the paths in the loaded HTML fragment are relative to the current
file and not to the HTML Fragment.
Regards,
Cristian MARIN -
XML data upload only from .xml file
Hi,
Can anyone let me know is ther any way how I can upload the data from .xml file into Oracle Table.
Note: I just want to upload the data from xml file; not entire .xml file.
I have data like as below in test.xml file and I want to upload the data only into TEST_EMP table:
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<TABLE_NAME>DEPT</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="2">
<TABLE_NAME>EMP</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="3">
<TABLE_NAME>BONUS</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="4">
<TABLE_NAME>SALGRADE</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="5">
<TABLE_NAME>BHAVESH_EMP</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
</ROWSET>
Any help would be highly appreciated!!
Thanks... BhaveshYou may convert the XML into a simple select and insert manually:
SQL> INSERT INTO test_emp
SELECT EXTRACTVALUE (t2.COLUMN_VALUE, '/ROW/TABLE_NAME') table_name,
EXTRACTVALUE (t2.COLUMN_VALUE, '/ROW/TABLESPACE_NAME')
tablespace_name
FROM TABLE
(XMLSEQUENCE
(EXTRACT
(XMLTYPE
('<?xml version = ''1.0''?>
<ROWSET>
<ROW num="1">
<TABLE_NAME>DEPT</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="2">
<TABLE_NAME>EMP</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="3">
<TABLE_NAME>BONUS</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="4">
<TABLE_NAME>SALGRADE</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
<ROW num="5">
<TABLE_NAME>BHAVESH_EMP</TABLE_NAME>
<TABLESPACE_NAME>USERS</TABLESPACE_NAME>
</ROW>
</ROWSET>
'/ROWSET'
) t,
TABLE (XMLSEQUENCE (EXTRACT (t.COLUMN_VALUE, '/ROWSET/ROW'))) t2 -
External XML data for more charts in a single page
I am using a plot chart which gets data from an external XML file through <mx:HTTPService>
I create another chart in the same page which also gets data from another XML file.
How can i provide data to this chart through the HTTP Service ?
- SenI hope i've understood well what you want to do.
Easily you could define 2 different httpservice with different url and bind them to chart.
hope this help!
bye! -
Updating an XML data in a table column.
Hi
I have a data in XML form stored in a clob column in a table. Now I need to merge an XML data (update) into this XML data.
For e.g.
XML 1:
======
<EMP>
<ROW>
<CODE>1</CODE>
<NAME>
<FIRST>abc1</FIRST>
<LAST>xyz1</LAST>
</NAME>
</ROW>
<ROW>
<CODE>2</CODE>
<NAME>
<FIRST>abc2</FIRST>
<LAST>xyz2</LAST>
</NAME>
</ROW>
<ROW>
<CODE>3</CODE>
<NAME>
<FIRST>abc3</FIRST>
<LAST>xyz3</LAST>
</NAME>
</ROW>
</EMP>
XML 2:
======
<EMP>
<ROW>
<MIDDLE>mno1</MIDDLE>
</ROW>
</EMP>
Result: XML 1 + XML 2 as given below
========
<EMP>
<ROW>
<CODE>1</CODE>
<NAME>
<FIRST>abc1</FIRST>
<MIDDLE>mno1</MIDDLE>
<LAST>xyz1</LAST>
</NAME>
</ROW>
<ROW>
<CODE>2</CODE>
<NAME>
<FIRST>abc2</FIRST>
<LAST>xyz2</LAST>
</NAME>
</ROW>
<ROW>
<CODE>3</CODE>
<NAME>
<FIRST>abc3</FIRST>
<LAST>xyz3</LAST>
</NAME>
</ROW>
</EMP>
As shown above I need to put the "Middle" tag from XML 2 into XML 1 and that to at a specific place in the XML 1 and not just append at the end of XML 1.
Any solution for?
Thanks,
Milton.There are two ways to do this:
1/ DOM API: importNode() and AdoptNode()
2/ XSLT Transformation -
How do I initialize an array after getting xml data via httpservice?
I am having a problem trying to initialize an array with data from an external xml file obtained via httpservice. Any help/direction would be much appreciated. I am using Flex 4 (Flash Builder 4).
Here is my xml file (partial):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Root>
<Row>
<icdcodedanddesc>00 PROCEDURES AND INTERVENT</icdcodedanddesc>
</Row>
<Row>
<icdcodedanddesc>00.0 THERAPEUTIC ULTRASOUND</icdcodedanddesc>
</Row>
<Row>
<icdcodedanddesc>00.01 THERAPEUTIC US VESSELS H</icdcodedanddesc>
</Row>
<Row>
<icdcodedanddesc>00.02 THERAPEUTIC ULTRASOUND O</icdcodedanddesc>
</Row>
</Root>
Here is my http service call:
<s:HTTPService id="icdcodeservice" url="ICD9V2MergeNumAndDescNotAllCodes.xml"
result="icdcodesService_resultHandler(event)" showBusyCursor="true" />
(I have tried resultFormat using object, array, xml).
I am using this following Tour de Flex example as the base -http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500
and updating it with the httpservice call and result handler. But I cannot get the data to appear - I get [object Object] instead. In my result handler code I use "icdcodesar = new Array(event.result.Root.Row);" and then "icdcodesar.refresh();".
The key question is: How to I get data from an external xml file into an array without getting [object Object] when referencing the array entries. Thanks much!
(Tour de Flex example at http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500 follows)
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:local="*"
skinClass="TDFGradientBackgroundSkin"
viewSourceURL="srcview/index.html">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
@namespace local "*";
s|Label {
color: #000000;
</fx:Style>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private var names:ArrayCollection = new ArrayCollection(
["John Smith", "Jane Doe", "Paul Dupont", "Liz Jones", "Marie Taylor"]);
private function searchName(item:Object):Boolean
return item.toLowerCase().search(searchBox.text) != -1;
private function textChangeHandler():void
names.filterFunction = searchName;
names.refresh();
searchBox.dataProvider = names;
private function itemSelectedHandler(event:SearchBoxEvent):void
fullName.text = event.item as String;
]]>
</fx:Script>
<s:layout>
<s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" />
</s:layout>
<s:Panel title="Components Samples"
width="600" height="100%"
color="0x000000"
borderAlpha="0.15">
<s:layout>
<s:HorizontalLayout horizontalAlign="center"
paddingLeft="10" paddingRight="10"
paddingTop="10" paddingBottom="10"/>
</s:layout>
<s:HGroup >
<s:Label text="Type a few characters to search:" />
<local:SearchBox id="searchBox" textChange="textChangeHandler()" itemSelected="itemSelectedHandler(event)"/>
</s:HGroup>
<mx:FormItem label="You selected:" >
<s:TextInput id="fullName"/>
</mx:FormItem>
</s:Panel>
</s:Application>Hello,
Instead of extracting the first zero element from the vid array, you should take that out and connect it allone.
Attachments:
init.bmp 339 KB -
XML data encoding iso-8859-1 . Currently utf-16 is default encoding
Hello ABAP Gurus ,
Need a help from you .
Scenario : We have SAP4.7 enterprise version which we have now converted to Unicode system . There is a BSP application which talks to an external web application (Non Unicode) thru HTTP protocol and sends data thru XML.
Problem : Problem is at the time when BSP application prepares the XML While preparing XML data , before converting to Unicode environment the encoding was "iso-8859-1" . But now after Unicode conversion , the encoding is "UTF-16".
The XML data looks like
<?xml version="1.0" encoding="utf-16"?><DATA><ACTION>CREATE_TICKET</ACTION><CRI
I have tried replacing "utf-16" by "iso-8859-1 " . The interface works . But at the recieving end , ie external web application , the German umlauts appear as some garbage values .
I know we need to enforce encoding . I have tried with the following code but could not suceed . The encoding appears as "utf-16".
Following is the section of code which I have written in BSP application.
Daten in DOM-Baum wandeln
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
name = 'DATA'
dataobject = ls_cr_xml
IMPORTING
data_as_dom = if_dom
CHANGING
document = if_document
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
error_out text-f47 text-f48 space space.
ENDIF.
DOM-Baum in Character-Stream wandeln
if_pixml = cl_ixml=>create( ).
IF if_pixml IS INITIAL.
error_out text-f50 text-f53 space space.
ENDIF.
if_pstreamfact = if_pixml->create_stream_factory( ).
IF if_pstreamfact IS INITIAL.
error_out text-f51 text-f53 space space.
ENDIF.
if_postream = if_pstreamfact->create_ostream_cstring( string = xml_doc ).
IF if_pstreamfact IS INITIAL.
error_out text-f52 text-f53 space space.
ENDIF.
--Encoding--
data: gv_str type string.
data: gv_l_xml_encoding type ref to if_ixml_encoding.
data gv_l_resultb type boolean.
gv_str = 'ISO-8859-1' .
clear gv_l_xml_encoding.
call method if_pixml->create_encoding
EXPORTING
byte_order = 0
character_set = gv_str
RECEIVING
rval = gv_l_xml_encoding.
clear gv_l_resultb.
call method gv_l_xml_encoding->set_character_set
EXPORTING
charset = gv_str
RECEIVING
rval = gv_l_resultb.
call method if_document->set_encoding
EXPORTING
encoding = gv_l_xml_encoding.
----Append child -
CALL METHOD if_document->append_child
EXPORTING
new_child = if_dom
RECEIVING
rval = lv_return.
IF lv_return NE 0.
error_out text-f47 text-f49 space space.
ENDIF.
--Render the XML data to output stream--
CALL METHOD if_document->render
EXPORTING
ostream = if_postream.
After this section of code is executed , the variable xml_doc gets filled up with XML data .
<?xml version="1.0" encoding="utf-16"?><DATA><ACTION>CREATE_TICKET</ACTION><CRI
Can anybody help how to enforce encoding ?
Regards,
Laxman Nayak.Hi Aslam Riaz,
Did you find any solution..?
Kindly help me on this issue.
Thanks and Regards,
Shailaja Chityala -
Using external xml for spry menu help
Just started playing with DW CS3, I would like to know how to
insert a spry menu and get the xml data from an external file. Can
anyone point me at a suitable example or tutorial please?The video workshop has some great tutorials with spry.
http://www.adobe.com/designcenter/video_workshop/
Aram -
Creating schemas using xml data
Hi
I have a situation where I need to create
database schemas dynamically using <xml> data.
Any help in this regard will be much appreciated.
Thanks
RadheepI'm not sure how to write a Web Service, however data can be read from a flat file using XML Data > Load, however the flat file has to be formatted with appropriate XML tags, such as...
<data>
<variable name="Test">
<row><column>1</column><column>2</column></row>
<row><column>10</column></row>
</variable>
</data>
In addition, you have to write a scriptlet that resides on a web server, with which Xcelsius can communicate. Once your data is formatted, it is as simple as referencing the file location in the XML Data URL: field.
Web Service is a very popular solution, and probably better than XML Data in this case due to the large volume of data. If you do a forum search for "Web Service" you'll find many threads regarding its usage. -
Xml data into non-xml database.. solution anyone?
Hi,
My current project requires me to store the client's data on our servers. We're using Oracle9i. Daily, I will download the client's data for that day and load it into our database. My problem is that the data file is not a flat file so I can't use sql*loader to load the data. Instead, the data file is an xml file. What is the best way to load xml data into a non-xml database? Are there any tools similar to sql*Loader that will load xml data into non-xml database? Is it the best solution for the client to give me an XML dump of their data to load into our database, or should I request a flat file? My last resort would be to write some sort of a script to parse the xml data into a flat file, and then run it through sql*loader. Is this the best solution? One thing to note is that these files could be very large.
Thanks in advance.
-PVI assume that just putting the XML file into an
extremely large VARCHAR field is not what you want.
Instead, you want to extract data elements from the
XML and write them to columns in a table in your
database. Right?Yes. Your assumption is correct.
It sounds like you already have a script that loads a
flat file into your database. In that case I would
write an XSL transformation that converts the client's
XML into a correctly-formatted flat file.Thank you. I'll look into that. Other suggestions are welcome.
Maybe you are looking for
-
[CUPS] Unable to set my new CUPS server with an HP printer (solved)
Hello, I come from Gentoo and I just installed my new Arch Linux server on a notebook with 2 NIC ... Now, I'm trying to set the CUPS deamon to share printer (HP DESKJET 895Cxi) for 3 workstations in my LAN. Before, it was working (printer and linux .
-
Please help
-
I have a Mac Book Pro with Mac OS 10.5.8., With the last update, a Nokia N97, with the last update too. When I try to synchronize the Mac with the phone via BlueTooth, the process stops and the following message: martes 17 de noviembre de 2009 7:45
-
is there any solution for wifi & bluetooth (gone grey), not working in 4s post IOS 7.0.4 update?? pl require a solution badly !!!
-
Hi eveybody Anyone could help me ? .... I'm trying to start a remote server but gets the following error : Starting WebLogic Server .... The WebLogic Server did not start up properly. Exception raised: java.lang.NoClassDefFoundError: java/lang/reflec