Problem converting to INT from an XML file
Hi folks, I hope you can help with this one, as it's been driving me nuts...
Basically (and I'll try to keep this brief!) my project takes in an extremely basic XML file. I've never really done this before, but I seem to have got most of it working apart from taking in attribute values which I want to use as integers.
Essentially, each element relates to objects of a basic class I have set up, while each attribute relates to the variables for the object. When the XML file is read, a new object is set up for each element and is stored in a linked list. That was supposed to be the difficult bit, but it turns out it hasn't been...
The XML file looks a little bit like this (only the elements are shown to save space):
<Object name="My object" description = "blah" x_axis = "96" y_axis="23" />
<Object name="Another one" description = "blah, again" x_axis = "83" y_axis="40"/>
etc. etc. The problem relates to the x_axis and y_axis attributes. While the description and name attributes are assigned correctly, for some reason the x_axis and y_axis attributes are both given values of zero when I convert them from Strings to Ints. After much printing to the console, kicking and screaming, I think I've narrowed the problem down to the following code:
if (attrib.getName() == "x_axis")
int myX = Integer.parseInt(attrib.getValue()); // converting a string to an int
myObject.setSoundX_Axis(myX);
// And, of course, I do the same sort of thing for the Y axis.Anyone know why I'm getting zero values? Is it something to do with the way I'm converting the string to an int in Java?
Cheers for any help.
int myX = Integer.parseInt(attrib.getValue());I don't see anything wrong. Try printing out the value of attrib.getValue() to see if it is what you expect. You may want to try:
String s = "" + myX;
if ( s.compareTo(attrib.getValue() != 0 ) {
System.out.println("Don't compare: myX=" + myX + " getValue=" + attrib.getValue());
}
Similar Messages
-
How to display Japanese text from an XML file
Hiya,
I have various adapted mp3 players [called playlists on my site] which retrieve the songs and song titles/artists from an XML file. One of them plays Japanese music.
Most of the tracks are in English but I now have a couple of songs with Japanese titles and file names which I can't get to preview/display in Flash Pro CS5 [Mac]. I can type static Japanese text and it displays fine but Flash seems to be having a problem with the Japanese from the XML file.
Though I can find the English titles, etc, it would be nice if there were a way to display Japanese text from a 'multi-lingual' [English and Japanese] XML file [probably something really easy].
Thanks a bunch.
steveThis should help you:
http://http://www.packtpub.com/article/working-with-xml-in-flex3-and-java-1http://www.packtpub.com/article/working-with-xml-in-flex3-and-java-1 -
Exception while loading properties from an xml file
Hi all,
I've got a problem while loading properties from an XML file:
java.lang.ClassCastException: org.apache.xerces.dom.DeferredCommentImpl cannot be cast to org.w3c.dom.Element
ERROR - Cannot load properties from the specified file <./conf/login.prop> java.lang.ClassCastException: org.apache.xerces.dom.DeferredCommentImpl cannot be cast to org.w3c.dom.Element
at java.util.XMLUtils.importProperties(XMLUtils.java:97)
at java.util.XMLUtils.load(XMLUtils.java:69)
at java.util.Properties.loadFromXML(Properties.java:852)
at g2.utility.HRPMProperties.<init>(HRPMProperties.java:78)
at g2.utility.HRPMProperties.getInstance(HRPMProperties.java:94)
at g2.gui.workers.ApplicationSwingWorker.<init>(ApplicationSwingWorker.java:36)
at g2.main.Main.main(Main.java:37)but this code worked before, and I've got the xerces and xercesImpl packages in the classpath, anyone can give me an hint on how to fix the problem?Here there's the code that instantiates the HRPMProperties object loading the property file:
public class HRPMProperties extends Properties {
* A reference to myself.
protected static HRPMProperties mySelf = null;
* The property file to which load the configuration.
protected static String propertyFile = "./conf/login.prop";
* A set of static strings used as keys in the properties file.
public final static String DATABASE_URL = "database_url";
public final static String DATABASE_USERNAME = "database_username";
public final static String DATABASE_PASSWORD = "database_password";
public final static String REAL_USERNAME = "real_username";
public final static String REAL_PASSWORD = "real_password";
public final static String PHANTOM_LOGIN = "login_thru_phantom_user";
public final static String AUTOCONNECT = "autoconnect";
public final static String TRANSLATION_FILE = "translation_file";
* Builds up an empty properties map.
protected HRPMProperties(){
super();
this.reload();
* Builds up the property map from the specified input file. <B> The file must be in XML format</B>.
* In case of exception and/or problems reading from the specified file, an empty property map is returned.
* @param fileName the path and the name of the file with the XML representation of the properties.
protected HRPMProperties(String fileName){
super();
try{
this.loadFromXML(new FileInputStream(fileName));
}catch(Exception e){
Logger.error("Cannot load properties from the specified file <"+fileName+"> " + e);
e.printStackTrace();
* Provides an instance of the property class loaded from the default configuration file.
* @return the property instance
public static final HRPMProperties getInstance(){
if( HRPMProperties.mySelf != null )
return HRPMProperties.mySelf;
else{
HRPMProperties.mySelf = new HRPMProperties(HRPMProperties.propertyFile);
return HRPMProperties.mySelf;
}The constructor is the one triggering the exception, so there's a problem loading the XML property file. -
Sliding Flash Interface - Using Links from an XML file Problem
Hi All,
Working on a new site for the company i've recently started
working for... fairly new to flash but wanted to try this sliding
interface for the graphic banner at the top of the page...
have a look here at an early version of the site - sliding
graphic interface at the top with coloured rollover buttons (a lot
of work still to do! feel free to post constructive criticism)
(am I allowed to post links??)
here is the unfinished version with no links in the flash bit
http://www.westfieldhealth.com/website/index.asp
The Problem:
I am pulling in a 'heading' 'text' and 'image' into the
sliding graphic interface from the following xml file... (there are
4 different xml files for 4 different slides)
<?xml version="1.0" encoding="iso-8859-1"?>
<content>
<dialogue>
<heading>Interested in selling our health
plans?</heading>
<text>Click here to learn more...</text>
<img>home_window/intSmall.jpg</img>
</dialogue>
</content>
I want to add a link to the xml that would be specific to
each instance of the window...
eg
<link>contact-us/index.asp</link>
But my limited knowledge of flash means I have no idea how to
pull the link through from the xml file to use in the flash...
Perhaps I need link text to pull as well
eg
<link-text>click here to contact us</link-text>
Here is the function that pulls in the img, heading and txt
public function onComplete(event:Event):void {
var loader:URLLoader = event.target as URLLoader;
if (loader != null) {
externalXML = new XML(loader.data);
mover_mc.heading_txt.htmlText =
externalXML.dialogue[0].heading;
mover_mc.myText_txt.htmlText = externalXML.dialogue[0].text;
var url:URLRequest = new
URLRequest(externalXML.dialogue[0].img);
myLoader.load(url);
} else {
trace("loader is not a URLLoader!");
Can anyone help me on how to pull in the link from the xml
and use it to navigate to a different page on the site
Thanks very much
Hans
link to
my unfinished flash file...What is the exact error you get (what db version also), could you post a simplified version of the SQL which fails also? I have splitter based maps that successfully read from file via the XMLType(bfilename....) style code and insert into multiple targets, I did this on 11g though.
Cheers
David -
Using HTTPService to import data from a XML file
Hello there!
I'm having some problem's with this import... If anyone can
help, I would appreciate it!
I'm using this type of information as data source:
public var dataCollection:ArrayCollection =
new ArrayCollection([
{ id: "P1", name: "Porto", type: "team", children: [
{ id: "R1", name: "Dr Silva", location: "Bloco 1", type:
"member" },
{ id: "R2", name: "Dra Neto", location: "Gabinete", type:
"member"
{ id: "P2", name: "Braga", type: "team", children: [
{ id: "R3", name: "Dr Santos", location: "Bloco 2", type:
"member" },
{ id: "R4", name: "Dra Sonia", location: "Piso 1", type:
"member"
But I want to import it from a XML file like this:
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="P1" name="Porto" type="team">
<children id="R1" name="Dr Silva" location="Bloco 1"
type="member" />
<children id="R2" name="Dra Neto" location="Gabinete"
type="member" />
</item>
<item id="P2" name="Braga" type="team">
<children id="R3" name="Dr Santos" location="Bloco 2"
type="member" />
<children id="R4" name="Dra Sonia" location="Piso 1"
type="member" />
</item>
</items>
I already import the file, but can not translate the data
into a array collection.
private function initApp():void {
var httpService:HTTPService = new HTTPService();
httpService.url = "dataprovider.xml";
httpService.resultFormat = "e4x";
httpService.addEventListener(FaultEvent.FAULT,
onFaultHttpService);
httpService.addEventListener(ResultEvent.RESULT,
onResultHttpService);
httpService.send();
private function onFaultHttpService(e:FaultEvent):void
Alert.show("Error reading data file.");
private function onResultHttpService(e:ResultEvent):void
//Convert the xml data to a array collection
Thank youHello Peter, and thank you for your reply's.
My problem is that I'm receiving the data from the external
file and I don't know how to get the children in place... I mean, I
also have some data being received form a file that I can convert
into an array collection, but the thing is, that file doesn't have
children structure...
It's something like this:
<?xml version="1.0" encoding="utf-8"?>
<items>
<item id="T1" resourceId="R1" name="Cardiologia"
startTime="25-3-09 8:0:0" endTime="25-3-09 8:30:0" />
<item id="T2" resourceId="R2" name="Raio-X"
startTime="25-3-09 9:0:0" endTime="25-3-09 9:15:0" />
<item id="T3" resourceId="R3" name="Analises"
startTime="25-3-09 12:0:0" endTime="25-3-09 12:45:0" />
<item id="T4" resourceId="R4" name="Consulta"
startTime="26-3-09 8:0:0" endTime="26-3-09 9:0:0" />
</items>
And I solve it with this (don't know if is the best):
private function onResultHttpServiceTask(e:ResultEvent):void
var a:Array = xmlListToObjectArray(e.result.item);
tasks = new ArrayCollection(a);
protected function
xmlListToObjectArray(xmlList:XMLList):Array
var a:Array = new Array();
for each(var xml:XML in xmlList)
var attributes:XMLList = xml.attributes();
var o:Object = new Object();
for each (var attribute:XML in attributes)
var nodeName:String = attribute.name().toString();
var value:*;
value = attribute.toString();
o[nodeName] = value;
a.push(new ObjectProxy(o));
return a;
But when the children "enter in action" I don't know how to
bring them to the array...
This code you send it's preaty much the thing I need, but the
thing is that I don't know how to call the children with data as
e:ResultEvent...
If you can help a bit more, I would really appreciate...
Thank You -
Creation of a shipping notification for a PO in EBP from a XML file via XI.
Hi everybody.
We are trying to create a shipping notification for a Purchase Order in Enterprise Buyer from a XML file via XI.
For to do it, we are using DespatchedDeliveryNotification_In message interface (transaction SPROXY).
But when we execute it, the system show us next message:
"An error occured within an XI interface: An exception with the type CX_GDT_CONVERSION occurred, but was neither handled locally, nor declared in a RAISING clause Programm: SAPLBBP_BD_MAPPING_SAPXML1; Include: LBBP_BD_MAPPING_SAPXML1F5B; Line: 4"
No more information is available.
Is there any additional transaction to see more information about the error message?
Is there any documentation about this XML file, mandatory fields, examples ?
We populated some fields in our XML file, but we do not know if the problem is with mandatory fields, data, program error
I will thank for any information
Thanks in advance.
Raúl Moncada.Raúl,
This is because of the inbound UOM.
The include LBBP_BD_MAPPING_SAPXML1F5B is in charge of mapping the item Unit Of Mesure (UOM) sent in the ASN XML file (it should be an ISO code).
You can test FM UNIT_OF_MEASURE_ISO_TO_SAP with this inbound ISO code.
PS: you should create an OSS message so the mapping sends back an error message instead of generating an uncatched exception (that generates a dump).
Rgds
Christophe
PS: please reward points for helpfull answers -
Need to insert values into a table from a XML file
Hi,
I'm an Oracle 9i/10g DBA with quite a few years experience, but I'm new to XML and dealing with it in database terms. I've been given a project that entails pulling XML values out of a file (or 100's of them) and storing them in the database so that they are searchable by end-users. The project is classified as secret so I'm unable to upload the specific XML or any info relating to the structire of the XML or the table I will use to insert the values into - sorry!! So, I've created an XML file with a similar structure to help people understand my predicament.
The end-users only need to search on a subset of the total amount of columns from the table I'll insert data into, although the XML file has a lot more, so I dont need to store the other values - but I will need to store the name of the XML file (or a pointer to it so I know what XML file a particular set of values belong to) in another column of the table along with its associated values.
I've been using the XMLTABLE function with some degree of success, although I had better succes using the XMLSEQUENCE function. However, I found out this is deprecated in 10g and replaced with XMLTABLE, so I guess it's better if I use this in case we ever need to upgrade to 11g.
The main problem I've been having is that some elements in the XML files have multiple values for the one record when all the other records are the same. In terms of storing this in the database, I guess it would mean inserting multiple rows in the table for each element where the value differs. Here is a dumbed down XML file similar to what I've got along with the other SQL I've used:
+<?xml version="1.0" encoding="UTF-8"?>+
+<House>+
+<Warehouse>+
+<WarehouseId>1</WarehouseId>+
+<WarehouseName>+
+<Town>Southlake</Town>+
+<State>Texas</State>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>25000</Area>+
+<Docks>2</Docks>+
+<DockType>Rear load</DockType>+
+<WaterAccess>true</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Street</Parking>+
+<VClearance>10</VClearance>+
+</Warehouse>+
+<Warehouse>+
+<WarehouseId>2</WarehouseId>+
+<WarehouseName>+
+<Town>Poole</Town>+
+<State>Dorset</State>+
+</WarehouseName>+
+<WarehouseName>+
+<Town>Solihull</Town>+
+<County>West Midlands</State>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>40000</Area>+
+<Docks>5</Docks>+
+<DockType>Rear load</DockType>+
+<WaterAccess>true</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Bay</Parking>+
+<VClearance>10</VClearance>+
+</Warehouse>+
+<Warehouse>+
+<WarehouseId>3</WarehouseId>+
+<WarehouseName>+
+<Town>Fleet</Town>+
+<County>Hampshire</County>+
+</WarehouseName>+
+<Building>Owned</Building>+
+<Area>10000</Area>+
+<Docks>1</Docks>+
+<DockType>Side load</DockType>+
+<WaterAccess>false</WaterAccess>+
+<RailAccess>N</RailAccess>+
+<Parking>Bay</Parking>+
+<VClearance>20</VClearance>+
+</Warehouse>+
+</House>+
CREATE TABLE xmltest OF XMLTYPE;
INSERT INTO xmltest
VALUES(xmltype(bfilename('XML_DIR', 'test.xml'), nls_charset_id('AL32UTF8')));
Consequently, I need to...
1) Retrieve the results from the XML file for all 3 warehouses where multiple values for the same sub-element are shown as 2 rowsthe result set. (I am guessing there will be 4 rows returned as warehouse sub-2 has 2 different elements for <WarehouseName>.
2) Build a case statement into the query so that regardless of the sub-element name (i.e State or County), it is returned into the 1 column, for instance County.
So, if I run a query similar to the following...
select y.WarehouseId, y.Town, y.County, y.Area
from xmltest x, xmltable('/House/Warehouse' .......
I would like to get results back like this...
ID Town County Area
1 Southlake Texas 25000
2 Poole Dorset 40000
2 Solihull West Midlands 40000
3 Fleet hampshire 10000
Sorry for the non-formatting but I hope this all makessense to someone out there with what I'm trying to do.
I appreciate any help whatsoever because, as i said before, I'm totally new to XML and trying to read the vast amount of information there is out there on XML is all a bit daunting.
Many thanks in advance,
Shaun.Hi again,
Thanks for keeping the post open for me. I've had a look at the post illustrating the XFileHandler package, and tried to alter it to make it fit with my XML files. To help explain things, my XML file looks like this:
<?xml version="1.0"?>
<!DOCTYPE CMF_Doc SYSTEM "CMF_Doc.dtd">
<House>
<Warehouse>
<WarehouseId>1</WarehouseId>
<WarehouseName>
<Town>Southlake</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>House
<WarehouseId>2</WarehouseId>
<WarehouseName>
<Town>Poole</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Solihull</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>40000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>3</WarehouseId>
<WarehouseName>
<Town>Fleet</Town>
<County>Hampshire</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>
<?xml version="1.0" encoding="UTF-8"?>
<House>
<Warehouse>
<WarehouseId>4</WarehouseId>
<WarehouseName>
<Town>Dallas</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>5</WarehouseId>
<WarehouseName>
<Town>Dorchester</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Solihull</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>40000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>6</WarehouseId>
<WarehouseName>
<Town>Farnborough</Town>
<County>Hampshire</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>
<?xml version="1.0" encoding="UTF-8"?>
<House>
<Warehouse>
<WarehouseId>7</WarehouseId>
<WarehouseName>
<Town>Southlake</Town>
<State>Texas</State>
</WarehouseName>
<Building>Owned</Building>
<Area>25000</Area>
<Docks>2</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Street</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>8</WarehouseId>
<WarehouseName>
<Town>Bournemouth</Town>
<State>Dorset</State>
</WarehouseName>
<WarehouseName>
<Town>Shirley</Town>
<County>West Midlands</County>
</WarehouseName>
<Building>Owned</Building>
<Area>30000</Area>
<Docks>5</Docks>
<DockType>Rear load</DockType>
<WaterAccess>true</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>10</VClearance>
</Warehouse>
<Warehouse>
<WarehouseId>9</WarehouseId>
<WarehouseName>
<Town>Clapham</Town>
<County>London</County>
</WarehouseName>
<Building>Owned</Building>
<Area>10000</Area>
<Docks>1</Docks>
<DockType>Side load</DockType>
<WaterAccess>false</WaterAccess>
<RailAccess>N</RailAccess>
<Parking>Bay</Parking>
<VClearance>20</VClearance>
</Warehouse>
</House>And the XFilehandler package looks like this (I'm just trying to do a simple select only on WarehouseId & WaterAccess for the time being to keep things simple):
create or replace package XFileHandler as
TYPE TRECORD IS RECORD (
WID NUMBER(2)
, WACCESS VARCHAR2(5)
type TRecordTable is table of TRecord;
function getRows (p_directory in varchar2, p_filename in varchar2) return TRecordTable pipelined;
end;
create or replace package body XFileHandler is
function getRows (p_directory in varchar2, p_filename in varchar2)
return TRecordTable pipelined
is
nb_rec number := 1;
tmp_xml clob;
tmp_file clob;
rec TRecord;
begin
DBMS_LOB.CREATETEMPORARY(TMP_FILE, TRUE);
tmp_file := dbms_xslprocessor.read2clob(p_directory, p_filename);
LOOP
tmp_xml := regexp_substr(tmp_file, '<\?xml[^?]+\?>\s*<([^>]+)>.*?</\1>', 1, nb_rec, 'n');
exit when length(tmp_xml) = 0;
--dbms_output.put_line(tmp_rec);
nb_rec := nb_rec + 1;
select y.WID, y.WACCESS
into rec.WID, rec.WACCESS
from xmltable('/House' passing xmltype(tmp_xml)
columns WID NUMBER(2) PATH 'Warehouse/WarehouseId',
WACCESS VARCHAR2(5) PATH 'WaterAccess') y;
pipe row ( rec );
end loop;
dbms_lob.freetemporary(tmp_file);
return;
end;
end;Now, when I run the query:
select * from table(XFileHandler.getRows('XML_DIR', 'XFileHandler_test.xml'));I get the error: ORA-00600: internal error code, arguments: [17285], [0x5CFE8DC8], [4], [0x45ABE1C8], [], [], [], []
I had a look in the dump file for anything obvious, but nothing really stands out. Is there anything obvious in my code that I'm missing or something else which you may think could be causing this error, e.g in the regular expression regexp_substr?
Many thanks,
Shaun. -
Error in Reading data from a xml file in ESB
Hi,
i created a inbound file adapter service which reads data from a xml file and passes it to the routing service and from there updates to the database.....
(everything created in jdeveloper)
But i am getting error....it is not getting updated to the database...when i check the database(select * from table) its showing one row selected but i couldnt find the data....
Transformation mapping also i did...
i think may be some error in reading the data from the xml file but not so sure.....
please reply to this mail as soon as possible its very urgentMichael R wrote:
The target table will be created when you execute the interface, if you set the option on the flow tab as instructed in step #6 of the "Setting up ODI Constraint on CLIENT Datastore" Section.
Option Value
CREATE_TARG_TABLE trueHi Michel,
This was not my required answer.I am sorry that I was unable to clarify my question.Actually
+This project executed successfully with some warning.Target Table is automatically created in database and also populated with data.But when I right-click Target Datastore(in >Mapping Tab of the Interface), and then select Data to View Data that needs to be inserted in the target table.I get some error like this:-...+This above line is the result of my project my problem is
when I right-click Target Datastore(in Mapping Tab of the Interface), and then select Data to View Data that already inserted in the target table.Is not shown by the view data operation.
I meant to say I am facing this error
At the10(1010 written) step of
Creating a New ODI Interface to Perform XML File to RDBMS Table Transformation
wehre it says
Open the Interface tab. Select Mapping tab, right-click Target Datastore - CLIENT, and then select Data. View Data inserted in the target table. Close Data Editor. Close the tabs...
In my case when I use my sqldeveloper I can see data successfully inserted in my target table and also in error table (data that can't satisfy the constraint) .But I was unable to check this by following the above mentioned 10 th step and got this error.
Thanks -
Error loading data from an XML file using HTTPService
Hello All,
I have a runtime error that has got me beat at the moment I am building an App in Flash Builder 4 to run on AIR.
The error is as follows: TypeError: Error #1009: Cannot access a property or method of a null object reference.
What i'm Trying to Do:
I have 2 DropDownList controls, the first is populated with country names and the other with language options. All the 1st DropDownList control does
is set an image control to display the country flag and enable the 2nd DropDownList.
The 2nd DropDownList sets the langCode variable equal to the chosen language code. I then call the language function and pass it langCode. Using this variable, I build up the string
so that langFilePath will be equal to the XML file (which is "Lang_GBR.xml") location on my desktop and then call the HTTPService.
As soon as the language function is called, the runtime error occurs and highlights the line with btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu;
where I try to assign the button label with a new value from the XML file.
I suspect this may be a trivial error but I just can't see it at the moment.
Any help or guidance would be appreciated. Thanks
Code:
<fx:Script>
<![CDATA[
[Bindable]
public var langFilePath:String;
public var langDir:File = File.desktopDirectory;
public var langCode:String;
public function countrySelect_changeHandler(event:IndexChangeEvent):void
switch (countrySelect.selectedItem)
case ('United Kingdom'):
trace("Item Selected was: "+ countrySelect.selectedItem);
img_countryFlag.source = AngolaFlag;
break;
case ('France'):
trace("Item Selected was: "+ countrySelect.selectedItem);
img_countryFlag.source = AustraliaFlag;
break;
default:
break;
langSelect.enabled = true;
trace("1st dropdownbox");
public function langSelect_changeHandler(event:IndexChangeEvent):void
switch (langSelect.selectedItem)
case ('English'):
trace("Language Selected was: "+ langSelect.selectedItem);
langCode = "Lang_GBR";
break;
case ('French'):
trace("Language Selected was: "+ langSelect.selectedItem);
langCode = "Lang_FRA";
break;
language(langCode);
public function language(aParam:String):void
trace("Code Was: " + aParam);
trace("Lang dir: " + langDir.nativePath);
langFilePath = langDir.nativePath + "/" + aParam + ".xml";
trace("File to load: " + langFilePath);
trace("loadLangFile.url: " + loadLangService.url);
loadLangService.send();
btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu;
]]>
</fx:Script>
<fx:Declarations>
<s:HTTPService id="loadLangService" url="{langFilePath}"/>
</fx:Declarations>
<s:DropDownList x="10" y="201" id="countrySelect" prompt="Please Select Your Country" width="274" enabled="true" change="countrySelect_changeHandler(event)">
<s:DropDownList x="10" y="348" id="langSelect" prompt="Please Select Your Language" width="274" enabled="false" change="langSelect_changeHandler(event)">Don't sure about your XML structure, but for now i see the problem here between this 2 lines of code:
loadLangService.send();
btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu;
Think data that your httpService should receive just can't go so fast to populate the lastResult before you call it in the next line
Try adding a result listener to your service before you send it:
loadLangService.addEventListener(ResultEvent.RESULT, handler);
loadLangService.send();
function handler(event:ResultEvent):void {
btn_LS_mainMenu.label = loadLangService.lastResult.Lang.GlobalTags.btnMenu; -
Loading an xml file from an xml file
I'm trying to load an xml file from an xml file, but I'm
having problems. My first xml file is really simple - it only
contains one attribute with the name of another xml file in it
(eventually I will have multiple xml files in here and run a loop
on them...this is why I want to load an xml file from an xml file).
Currently, with the code below, I can get the main xml file
to load ("main.xml"), but I cannot get the secondary xml files to
load FROM the main.xml.
I want to then take childNode values from the secondary xml
file and use them within my .swf in text boxes and whatnot.
Any guidance? I think I'm going wrong on the line where I'm
saying "i.newxml.load(i.attributes.location);"
- How can I get this to work?johnypeter:
I tried changing the code inside the loop to use just
"newxml" instead of "i.newxml", and I declared with "var newxml =
new XML();" - was this what you were thinking?
kglad:
The reason I tried to use the loadXML() function in the loop
was so that for each node in my "main.xml" it would load the new
xml file listed - this is a no-no? Do you have any ideas as to what
I could do?
For the for-loop, what should I change in it? I'm not great
with loops so I tried to modify some code from another loop I found
in another forum thread - not the right way to do it here?
Also, what should I trace? The value of the _root.address, or
i.attributes.location? I have created dynamic text boxes on my
stage to see if the correct value from the xml file loads (ie. the
name of the xml file within the xml file) and it does, but now I
don't know how to put that information into ANOTHER loadXML()
function and get the node information from it - does that make
sense???
Below are the examples of the xml files I am using. In the
first one, main.xml, I will have a list of multiple xml files, each
with the same nodes and elements as in the details.xml file
(different values, of course).
This is just to give you an example of what I'm trying to
accomplish - pulling ALL the addresses and phone numbers from
multiple xml files. I cannot manually collect this information, as
it is dynamic, and will be updated in each individual details.xml.
I was hoping to collect the information by simply adding to and
updating ONE xml file - main.xml.
Do you think this can be done? Am I going about it the wrong
way? I'm quite limited in AS knowledge, which is why I'm piecing
together code from other posts! -
Draw a picture from a XML file
Hi,
the problem I have is the following.
We have a UI (JNET) where you can create a data model which later on will be analyzied for data conistency. All details of the data model are stored in an XML file. To document what we did we need to create a word report. This word report should also contain a pricure of the data model which should be included automatically. The creation of the report itself is not a problem but I have no idea how I can include the picture of the data model.
Is there a way of drawing/ a picture (jpg, gif, png, etc.) from a XML file using ABAP??
I attached an example of the data model. It is also the target which should be displayed from the XML file.
Thanks for your support.
Best regards,
NiklasHi,
Thanks for the reply.I got the solution for my problem.Actually i wanted to delete only a particular element.
The solution to this is after using
Element element = (Element)document.getElementsByTagName("job").item(r-2);
element.getParentNode().removeChild(element);
writeXmlFile(document,"xmlfilename");. -
Reading rule sets from an XML file
Hi all,
How can I read rule sets from an XML file? I have been given some rules in XML
format and using those I have to query some content. I am using WLP4.0
Also how can I code rules in java?
Thanks in advance.You can have the following classes:
Players class deriving from Vector (or containing a vector), and then
Player class with attribute 'name'.
class Players
Vector myVector = new Vector();
void addPlayer(Player p)
myVector.add(p);
Player getPlayer(int index)
myVector.get(index);
class Player
private String myName = null;
Player(String name)
this.myName = name;
String getName()
return myName;
}Then while handling the SAX events you can do the following:
class MySAXHandler implements ContentHandler (or whatever the itnerface is)
public void startElement(String name,....)
Players p = null;
if(name.equals("Players"))
p = new Players();
else if (name.equals("Name"))
p.add(new Player(value));
}HTH,
Kalyan. -
Importing Arabic text from an XML file
Importing text from an XML file to appear as text in Flash
works in English, however if the text I want to import is in
Arabic, when I test the movie there is no text at all.
Is there some particular syntax to preface the Arabic text?
I'll want to import text from XML in other languages too.
(French)
I'd cut and pasted some Arabic text into the XML file that
displays pictures and text in the "slideshow.fla" (
http://www.adobe.com/support/flash/applications/jpeg_slideshow_xml/jpeg_slideshow_xml03.ht ml)
Substituting Arabic text for English text, editing the XML
file with Dreamweaver.
Any ideas as to how I might achieve my objective of importing
Arabic text into Fash?
I'd started developing my prototpe in Macromedia Director 7,
and then Director MX, but I have not found a suitable Arabic font
that I can embed that will allow me to display Arabic fonts in
Adobe Director. I have the Arabic text in a Word document.
I've dicovered that my Flash MX Pro and Dreamweaver both
support Arabic fonts, but I want to import text from an XML file.
I'd prefer using cast libraries and cast members, but I don't
know of an equivalent in Flash to what I'm comfortable with in
Director.Oh so many questions. You probably aren't going to like the
answers. I have Flash MX04 pro (aka Flash 7) and things made a big
jump between MX (aka 6) and MX04. If you only have MX, there might
not be a way to do this. All my advice is based upon MX04 or
higher.
It is possible to do complex languages in Flash. My
experience is with Hindi and I've helped a few folks here with
Arabic.
You won't be able to use text from Microsoft Word – at
least I don't think so. The XML file will need to be saved in the
UTF-8 format. I think Word uses its own scheme and won't work. But
I'm not a Word expert. Something like Text Edit (Mac) or WordPad
(PC) should be able to save a UTF-8 file.
The next problem is you mention "suitable Arabic font that I
can embed." AFAIK, you can't embed any of the complex scripts in
Flash. You just have to rely on the end user having appropriate
fonts installed and enabled. Most operating systems from 2000 on do
have this – although some folks like to remove them to save
space.
Next issue will be line composing. I've found that when using
anything above the normal Latin range that Flash suddenly forgets
how to make a line fit into a text area. It will just break things
in the middle of words and not even notice the spaces between
words. I've written a little snippet of code that "composes" the
lines. It works well with Hindi and folks here have used it with
Arabic and not come back saying that it doesn't work. Search the
forums (both the Flash and Actionscript) if you can't find it I'll
dig it out when I get home.
So here is the checklist:
Make sure the XML is saved in UTF-8
Import the XML file
In Testing environment go Debug–>List variables.
Does it show up correctly there?
Does it show at all in a text field?
Use the "composer" to make the lines break. -
Pooling data from an XML file to another XML file using File Adapter
Hi,
I am trying to Pool data from an XML file to another XML file using File Adapter. I have added "Target Namespace" in both the XML and XSD.The problem is "At the destination given in the FileAdapter" only a blank XML file is created and it doesnot have any data.
Kindly suggest me some methods
Thanks in Advance.Ok here is a solution with external tables.
SQL> CREATE DIRECTORY my_xml_dir AS 'E:\oracle\Log_files\UTL_AKIVATST'
2 /
Directory created.
SQL> DROP TABLE my_xml_et
2 /
Table dropped.
SQL> CREATE TABLE my_xml_et
2 ( EMPNO NUMBER,
3 EMPNAME VARCHAR2(10),
4 JOB VARCHAR2(10),
5 HIREDATE DATE,
6 SAL NUMBER
7 )
8 ORGANIZATION EXTERNAL
9 (
10 TYPE ORACLE_LOADER
11 DEFAULT DIRECTORY my_xml_dir
12 ACCESS PARAMETERS
13 (
14 records delimited by "</EMP>"
15 badfile my_xml_dir:'empxt%a_%p.bad'
16 logfile my_xml_dir:'empxt%a_%p.log'
17 FIELDS
18 (
19 filler char(2000) terminated by "<EMP>",
20 EMPNO char(2000) enclosed by "<EMPNO>" and "</EMPNO>",
21 EMPNAME char(2000) enclosed by "<ENAME>" and "</ENAME>",
22 JOB char(2000) enclosed by "<JOB>" and "</JOB>",
23 HIREDATE char(2000) enclosed by "<HIREDATE>" and "</HIREDATE>",
24 SAL char(2000) enclosed by "<SAL>" and "</SAL>"
25 )
26 )
27 LOCATION ('emp.xml')
28 )
29 PARALLEL
30 REJECT LIMIT UNLIMITED
31 /
Table created.
SQL> SELECT * FROM my_xml_et
2 /
EMPNO EMPNAME JOB HIREDATE SAL
7369 SMITH CLERK 17-DEC-80 800
7499 ALLEN SALESMAN 20-FEB-81 1600
This is the XML file i used emp.xml
<EMPLOYEES>
<EMP>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
<HIREDATE>17-DEC-80</HIREDATE>
<SAL>800</SAL>
</EMP>
<EMP>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
<HIREDATE>20-FEB-81</HIREDATE>
<SAL>1600</SAL>
<COMM>300</COMM>
</EMP>
</EMPLOYEES>
Use this external table to insert into your table.
Thanks,
Karthick. -
Hello everybody,
My problem is this: I have to do a GUI from an XML file. I am a begginer in JAVA, in GUI development and in XML. So... my situation is a bit difficult. What I have in mind is, if possible, to have a kind of function (that maybe already exists) that opens the XML file, read the whole document, keep the information in some variables and, from them, I can build the GUI using Swing. Is it possible this? Any help please, any idea?
Thanks a lot!!
Fran.Of course, this is possible. But what kind of "GUI XML" are you talking about? Is the XML given? Does it already conform to some GUI-XML-API? Give more infos!
Maybe you are looking for
-
Firefox keeps crashing and no offer to send error report
In the past 7 days Firefox has crashed 5 times regardless of what I am doing on it. No option to send report or crash ID to Firefox, only window that pops up is choice to try to restore session. In the past this window has looked different...
-
I want to create a HD disc with my Adobe Premier Elements but I am getting low resolution. When I go to share the DVD to disc the form only offers 8pixels at the bottom. How do I burn this DVD in HD with higher number of pixels? I have read other
-
PL/SQL spatial query will not compile.
I have a PL/SQL spatial query that will not compile, but the equivalent SQLPlus query works fine. I.e. (convert decimal degrees to degrees,minutes,seconds) Any thoughts much appreciated.... THIS WORKS in SQLPlus select decode(rownum,1,decode(sign(b.c
-
Tolerance for moving average price.
Hi Gurus, I'd like to know if we can set a tolerance limit for moving average price.I'm not sure about the settings but I think ther should be a way of doing this. I'd really appreciate any suggestions. Thanks Cheris T
-
CRX DE bundle not deploying to Felix Console
Hi, I'm building a Bundle using CRX DE (not LITE). It builds OK, but doesn't get installed automatically to the Felix console. If I export the jar, I can import it manually OK. Is there anything it needs to deploy automatically? Anything I should