Parsing XML file with the word "Infinity" in it
I am having a problem within Flex that parses an XML file,
one of the text names within the file contains the word "Infinity".
Unfortunately this is a constant within Flex and the element of my
array does not think it is a text string but a value. I have tried
type setting the xml element, and putting escape characters around
the text but nothing works. If I change the text to lowercase
"infinity" it works fine.
Any help greatly appreciated.
This sounds like a bug. Can you file it, with a small code
example that illustrates it, here:
http://bugs.adobe.com/jira
Thanks!
matt horn
flex docs
Similar Messages
-
How to parse XML file with namesapce?
Hi,
I am trying to parse an xml file having namespace. But no data is returned.
Sample Code:
public class XMLFileLoader
var xml:XML = new XML();
var myXML:XML = new XML();
var XML_URL:String = "file:///C:/Documents and Settings/Administrator/Desktop/MyData.xml";
var myLoader:URLLoader = null;
public function XMLFileLoader()
var myXMLURL:URLRequest = new URLRequest(XML_URL);
myLoader= new URLLoader(myXMLURL);
myLoader.addEventListener(Event.COMPLETE,download);
public function download(event:Event):void
myXML = XML(myLoader.data);
var ns:Namespace=myXML.namespace("xsi");
for(var prop:String in myXML)
trace(prop);
//Alert.show(myXML..Parameters);
//trace("Data loadedww."+myXML.toString());
//Alert.show(myXML.DocumentInfo.attributes()+"test","Message");
The XML Contains the following format.
<Network xmlns="http://www.test.com/2005/test/omc/conf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.test.com/2005/test/omc/conf/TestConfigurationEdition3proposal4.xsd">
<TestDomain>
<WAC>
<!--Release Parameter -->
<Parameters ParameterName="ne_release" OutageType="None"
accessRight="CreateOnly" isMandatory="true"
Planned="false"
Reference="true" Working="true">
<DataType>
<StringType/>
</DataType>
<GUIInfo graphicalName="Release"
tabName="All"
description="Describes the release version of the managed object"/>
</Parameters>
</TestDomain>
</Network>
Any sample code how to parse this kind of xml file with namespaces...
Regards,
Purushothami have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
screenshot -
Parse xml file with validating againat dtd
i have a xlm file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE map SYSTEM "map.dtd">
<map width="20" height="15" goal="25" name="eXtreme Labyrinth of Dooom">
<random-item type='lantern' amount='5' />
<random-item type='health' amount='10' />
<tile x="14" y="0" type="wall">
<renderhint>wall:rock,cracked</renderhint>
</tile>
<tile x="15" y="0" type="wall" />
<tile x="16" y="0" type="floor">
<renderhint>floor:marble,cracked</renderhint>
</tile>
<tile x="17" y="0" type="floor">
<renderhint>floor:stone,rubble</renderhint>
</tile>
<tile x="18" y="0" type="floor" />
<tile x="0" y="1" type="floor" />
<tile x="1" y="1" type="floor" startlocation="1" />
<tile x="2" y="1" type="floor" />
<tile x="3" y="1" type="floor">
<item type="treasure">Bar of Silver</item>
<renderhint>floor:stone,blood</renderhint>
</tile>
<tile x="4" y="1" type="wall" />
<tile x="5" y="1" type="wall" />
<tile x="6" y="1" type="wall">
<renderhint>wall:bricks,cracked</renderhint>
</tile>
</map>and a dtd document like:
<!ELEMENT map (random-item+, tile+)>
<!ATTLIST map
width CDATA #REQUIRED
height CDATA #REQUIRED
goal CDATA #REQUIRED
name CDATA #REQUIRED
<!ELEMENT random-item EMPTY>
<!ATTLIST random-item
type (armour|health|sword|treasure|lantern) #REQUIRED
amount CDATA #REQUIRED
<!ELEMENT tile (item|renderhint)*>
<!ATTLIST tile
x CDATA #REQUIRED
y CDATA #REQUIRED
type (exit|floor|wall) #REQUIRED
startlocation CDATA #IMPLIED
<!ELEMENT item (#PCDATA)>
<!ATTLIST item
type (armour|health|sword|treasure|lantern) #REQUIRED
<!ELEMENT renderhint (#PCDATA)>i need to validate the xml file against the dtd document and parse it to java using DOM.
Can anyone give ma any suggestions on how to do it?
thank youi have started my coding like:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import java.io.*;
class loadxml
public static void main(String[] args)
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setIgnoringElementContentWhitespace(true);
DocumentBuilder parser = factory.newDocumentBuilder();
Document doc = parser.parse(new File("hallways.xml"));
loadxml load = new loadxml();
load.parseNode(doc);
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
public void parseNode (Node node) throws IOException
// here is where i have problem with
}since in my xml file, i have got ATTLIST, this ready confuses me when i try to coding it.
Can anyone help me, please.
Thank you.
Edited by: mujingyue on Mar 12, 2008 3:10 PM -
Parsing XML file with different languages (Xerces)
How do we code or program to an XML file with different
languages , say english and spanish. WHen we parse such a document with the default locale , the presence of special characters throws errors .For eg when I use xerces and use
DOMParser parser = new DOMParser();
try
// Parse the XML Document
parser.parse(xmlFile);
catch (SAXException se)
se.printStackTrace();
org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0xfc) was found in the element content of the document.
System Error: void org.apache.xerces.framework.XMLParser.parse(org.xml.sax.InputSource)
So what locale do we set before we parse ?How to handle this problemYou need an encoding attribute in the xml declaration. If you don't, the parser assumes UTF-8, which are ASCII characters up to 127 - useful (only) for English.
So, something like this would allow you to use characters above 127, ISO-8859-1 is the encoding used by standard PCs.
<?xml version="1.0" encoding="ISO-8859-1"?>
You can find a (offical) list of encodings at:
http://www.iana.org/assignments/character-sets
I'm not sure about mixing various encodings. I think you have to resort external parsed entities, which can have their own encoding, but I think you cannot mix encodings in one XML file.
Good luck. -
Creating XML files with the DME
Hi All,
I'm working on an integration project between my company and HSBC, they are requesting that we supply our AP payment files for foreign currency in XML format.
I have some limited experience with the DME and know it can create XML files, however, the elements available for XML files are different to standard flat files. Also it doesnt seem like I can create files with multiple levels? e.g.
<InitgPty>
......... <Id>
............... <OrgId>
...................... <BkPtyId>ABC00103003</BkPtyId>
.............. </OrgId>
........ </Id>
</InitgPty>
Does anyone have any documentation or experience with creating XML files with DME?
thanks
Phil.Hi,
Please ask any Implementation team in ABAB or Report painter team with your friends,
Thanks and REgards
N.Soma Sundaram -
Detection of encoding of XML file with the StAX parser
Hello!
I am using the StAX parser to read an XML file which can have different encodings.
I don't know how to detect the encoding before reading the file.
This is the way I instantiate the reader now:
XMLStreamReader xmlr = xmlif.createXMLStreamReader(new InputStreamReader (new FileInputStream(inputfile), "utf-8"));
Is there any way to make the reader detect the encoding with StAX? Is it possible detect the encoding with SAX or DOM?
Just paste some piece of code and you will help me a lot!
Thanks,
LaraXML parsers are supposed to auto-detect the encoding of their inputs. The SAX and DOM parsers built into Java, as well as others like Xerces, do that. I don't know whether your StAX parser does, but it should. There is a standard procedure for determining the encoding that is described in the XML spec.
However if you have malformed XML that fails to declare its encoding properly, then none of those parsers will be able to fix that problem for you.
Here's the simplified rule as it applies to most files: if the XML file doesn't have a prolog, or if it's prolog doesn't specify an encoding, the parser will assume the file's encoding is UTF-8. If the XML file does have a prolog that specifies an encoding, the parser will assume that encoding.
Unfortunately it is common for people to write XML files that don't declare an encoding, but to forget to encode the file in UTF-8. Then you have a file that is actually encoded in (e.g.) Windows-1252, but the parser believes it is UTF-8, and this fails when there are non-ASCII characters in the document. -
Hi,
Is that possible to parse a xml file using regular expressions....if s what is the API needed
thanx in advanceIs that possible to parse a xml file using regular
expressions....if s what is the API neededI'm sure it can be done. Here's the regex API:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/package-summary.html
http://www.javaregex.com/tutorial.html
But that's not where regex is for. Better have a look at this:
http://java.sun.com/xml/ -
Creation of XML files with the DME Engine
Hi Experts,
For a Belgium client, I have a requirement to generate DME file in XML format for payments made to foreign and domestic vendors. I want to know the following,
1. Can DME file be generated in XML format using classic payment medium programs RFFOBE_E and RFFOBE_I.
2. If not why and what are the other options.
3. I also came to know that there is an options of using Payment medium workbench - through XML format trees BE_BEPDTA and BE_PIBDTA. But since we are in 4.6C, i am not able to create a payment format. Is there any support package or patch that is required.
4. I tried for SEPA_CT - again a XML format tree but was not very successful as that too was not available in SAP 4.6C. Is there any way that I can get this done in 4.6C - any support packages or patches available?
ThanksHEllo,
1.Classic RFFO* programs don't support XML files. Technical constraint.
2.XML can be generated through DME tree ( PMW in this case ).
3.PMW is available as of 4.6C SP 34.
4.XML is available in DME Engine as of 4.6C SP 47.
REgards,
Renan Correa -
How to generate a html file from a xml file with the default Firefox look and feel
Hello
Any xml or xsd file are pretty printed with Mozilla firefox. I would like to generate the equivalent html file, in order to introduce it later in a Word document. Do you use a xslt file ? How can I do this ?
Best regardsI would be remiss if I did not point out that the forum software detected your Firefox as version 17. Is that correct?
Version 17 is not secure; Mozilla discloses [https://www.mozilla.org/security/known-vulnerabilities/firefox.html security flaws] after each new release. Is something holding you back from upgrading to Firefox 31? Please let us know so we can suggest solutions or workarounds.
If Help > About Firefox shows Firefox 31, you may need to clear the preference that is misreporting your version number. See: [[Websites say that Firefox is outdated or incompatible even though it's the latest version]]. -
Open XML file with user default browser and not the default editor.
Hi,
I'm writing a java program that appends numerous XML files together. The result is a NEW well formed XML document. Since i have an XSLT that performs several UI modifications on this xml file, the file extension must remain '.xml'. I need to open this xml file with the users default web browser. The problem is that:
Runtime.getRuntime().exec(cmd);
....opens the xml file with the users default program for opening xml files which in my case is Oxygen. I want to force java to open this xml file with the users default web browser and nothing else.
I guess i need the Windows command to perform the 'open with' feature but i have no idea what that command is or how to find it.
Any ideas?
Thanks,
Varun Singh
Edited by: Jagara00 on Jul 2, 2009 3:49 PMsabre150 wrote:
Jagara00 wrote:
Your right, but my question relates to the java issue and not the XSLT aspect of the problem. I am looking for a java solution for reasons i will no go into here. You have lost me.Me too.
People do not often ask questions (or make challenges or observations) idly for the sake of 'theory'. It is most useful to explain to the best of your ability.
As to
"Since the Desktop class was only released with SE 6 I am forced to find another alternative. "
There is an 'alternative'. You can import it into a 1.5 project. It was available as a free standing API before 1.6 - through JDIC. See [https://jdic.dev.java.net/documentation/Examples.html|https://jdic.dev.java.net/documentation/Examples.html] for more info.
Edit 1:
To a later reply
"Do u .."
..want to spell incorrectly when you get frustrated?
"..do not wish to.."
..get any help? That is the way you are heading.
Edited by: AndrewThompson64 on Jul 3, 2009 9:27 AM -
Generation of Xml file with java output
Hi i m new to xml and java combination. I have a name value pair kind of output returning from java program. I want to generate the new xml file with the data. Could some one help me out in generating xml file with the data. Could anyone send me the java code that does this task.
Let me know which parser are you using currently for reading xml files so that i assist you. For now, you can refer to STAX Parser API under this link
http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP3.html -
Combine several XML files with same structure
Hello,
I have several XML files with the same structure and I want to combine them and create a new XML file to be bale to compare that information easily. It does not look very difficult but as I am very new in this I am not bale to get it
The structure of my actual files would be something simlar to:
Root->...-> Name->Address, Telephone
And what I would like to have si something like
Root->.... ->Address-> Name 1,Name 2....
Root -> ...->Telephone-> Name 1, Name 2....
Does anyone know how to do this.
ThanksYou could write a XSL transformation file that does this and transform your input file via
* Transform XML file with a style sheet.
* <p><b>Example:</b><p>
<table align="center" bgcolor="#E0E0E0" border=1 cellpadding="10" cellspacing="0"><tr><td><pre style="margin-top:0; margin-bottom:0">
XMLTransformer t = new XMLTransformer();
FileOutputStream fos = new FileOutputStream("C:/Project/result.html");
String xmlFile = "C:/Project/source.xml";
String styleSheet = "C:/Project/stylesheet.xsl";
t.transform(xmlFile, styleSheet, fos);
</pre></td></tr></table>
* @param xmlfile The XML file to transform.
* @param style Stylesheet to use for transformation.
* @param outputStream OutputStream to write the transformed result to.
public void transform(String xmlfile, String style, OutputStream outputStream) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//factory.setNamespaceAware(true);
//factory.setValidating(true);
//todo: use inputstreams instead of file names
try {
File stylesheet = new File(style);
File datafile = new File(xmlfile);
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(datafile);
// Use a Transformer for output
TransformerFactory tFactory = TransformerFactory.newInstance();
StreamSource stylesource = new StreamSource(stylesheet);
Transformer transformer = tFactory.newTransformer(stylesource);
DOMSource source = new DOMSource(document);
StreamResult sr = new StreamResult(outputStream);
transformer.transform(source, sr);
} catch (TransformerConfigurationException tce) {
// Error generated by the parser
System.out.println ("\n**XMLTransformerr Factory error");
System.out.println(" " + tce.getMessage() );
// Use the contained exception, if any
Throwable x = tce;
if (tce.getException() != null) {
x = tce.getException();
x.printStackTrace();
} catch (TransformerException te) {
// Error generated by the parser
System.out.println ("\n** Transformation error");
System.out.println(" " + te.getMessage() );
// Use the contained exception, if any
Throwable x = te;
if (te.getException() != null) {
x = te.getException();
x.printStackTrace();
} catch (SAXException sxe) {
// Error generated by this application
// (or a parser-initialization error)
Exception x = sxe;
if (sxe.getException() != null) {
x = sxe.getException();
x.printStackTrace();
} catch (ParserConfigurationException pce) {
// Parser with specified options can't be built
pce.printStackTrace();
} catch (IOException ioe) {
// I/O error
ioe.printStackTrace();
}//transform() -
Converting Dom Document object into XML file removes the DTD
Hi All
My xml is dtd. I have one xml file. i changed the node value after that i want to create a xml file with the same name. I created new xml file but i am not seeing the old dtd in the new file. This process is done with the help of jaxp.
My code is given below
File fileInput = new File("input.xml");
File fileOutput = new File("output.xml");
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setExpandEntityReferences(false);
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(fileInput);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "true");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
DOMSource source = new DOMSource(document);
FileOutputStream fos = new FileOutputStream(fileOutput);
StreamResult result = new StreamResult(fos);
transformer.transform(source, result);
Thanks in advanceThe Transformer API does not guarantee the preservation of that information. You may want to check the DOM L3 Load/Save package (http://java.sun.com/javase/6/docs/api/index.html). Alternatively, you may force things by setting the additional output properties 'doctype-public' and 'doctype-system'.
-
File Adapter : read XML file with data validation and file rejection ?
Hello,
In order to read a XML file with the file adapter, I have defined a XSD that I have imported to my project.
Now the File Adapter reads the file correctly but it does not give an error when:
- the data types are not valid. Ex: dateTime is expected in a node and a string is provided
- the XML file has invalid attributes.
How can I manage error handling for XML files ?
Should I write my own Java XPath function to validate the file after is processed ? (here is an example for doing this : http://www.experts-exchange.com/Web/Web_Languages/XML/Q_21058568.html)
Thanks.one option is to specify validateXML on the partnerlink (that describes the file adapter endpoint) such as shown here
<partnerLinkBinding name="StarLoanService">
<property name="wsdlLocation"> http://<hostname>:9700/orabpel/default/StarLoan/StarLoan?wsdl</property>
<property name="validateXML">true</property>
</partnerLinkBinding>
hth clemens -
Parse exisitng xml file and recreate another xml file with different struct
Is it possible in java using dom parser to parse an exisiting xml file and recreate a new xml file from data obtained by parsing old xml file.
I checked on old forum threads and everywhere either parsing xml file has been explained or creating new xml file from scratch has been shown.
Any examples/guidance will be appreciated....The general process is:
Document dom1 = ... // the parsed document
Document dom2 = ... // new document constructed on the fly
Node nD1 = ... // some random node found in dom1
// copy the node from dom1 and associate with dom2
Node nD2 = dom2.importNode(nD1, true);
// ... treat nD2 as a node which can now be inserted into dom2 ...
Node otherD2 = ... // some other node already in dom2
otherD2.appendChild(nD2);Note, in this example the nD1 node is copied (including any sub-nodes) into a new node, nD2. You can alternately move the node from one Document to another using Document.adoptNode(), however this may fail (see the javadoc).
Maybe you are looking for
-
What internal hard drive can I get with 2007 Mac Pro?
Hello, I own a Mac Pro that I purchased sometime Early 2007 and I want to add an additional internal hard drive. I am a little confused as to what my options are after visiting the Apple online store. It seems they do not have a choice for 1 TB drive
-
Removing children from List causes visual bug
Hello, I'm new to Flex so I apologize if this is basic and trivial. I have a list that I'm using some databinding with some search results. After the initial search I need to clear out all of the children in the list before running the next search ot
-
Inventory Balances 0IC_C03
Hi All; I created a query to display opening and closing Inventory qty and value for a specific month based on key date entered by the user. I have created a userexit for variable which determines Last day of month and last day of previous month base
-
TS1702 how do i tranfer a game to another device with out loseing a level?
i have to send my iphone 4s in for a replacement phone because my speaker quit working on my phone and right now i have a iphone 3 which i dont like as well as the 4s and i'm trying to tranfer my game along with the levels that i'm at and i was wonde
-
Can i Use Muvo TX FM firmware on Muvo TX....so i can use Fm radio...because the hardware is the same...