views:

202

answers:

1

So I'm working on a quick utility to allow simple editing for TMX files. TMX is basically an XML-based standard for storing multilingual translations. Anyhoo, I'm importing TMX into an Adobe AIR app via a File reference, then grabbing the file stream, slapping the UTF-8 characters into a string, and then that string into an XML object. THus:

var stream:FileStream = new FileStream();
stream.open(event.target /*file data*/ as File, FileMode.READ);
var fileData:String = stream.readUTFBytes(stream.bytesAvailable);
var tmxXml:XML = new XML(fileData);

But, here is the interesting part. If fileData is loaded as this:

<tuv xml:lang="en">
    <seg>About Us</seg>
</tuv>

Flex's XML interprets it as this:

<tuv aaa:lang="en" xmlns:aaa="http://www.w3.org/XML/1998/namespace"&gt;
    <seg>
        About Us
    </seg>
</tuv>

Oh ho interesting! The attribute xml:lang becomes aaa:lang="en" xmlns:aaa="http://www.w3.org/XML/1998/namespace". From my brief research, there is some precedent for this happening, but it's somewhat a sucky assumption. Without creating excessive string replace rules, is there a way to circumvent this?

A: 

Have you tried using one of the following?

 default xml namespace = xml;

or,

 use namespace xml;

Go through the Namespaces documentation.

dirkgently