XML Parsing Help needed
Thread poster: petercallen
petercallen
petercallen
United States
Local time: 20:10
Apr 24, 2014

I have the following text in a string in an XML file I am processing with Studio 2014.

<DragType>
<DragText font="Tahoma" font-color="00ccff" font-size="11" startLeft="-2" startTop="352" targetLeft="134" targetTop="175" text="Baggage Fees" />
<DragType/>

text="Baggage Fees"

The text - Baggage Fees - needs to be translated but it does not show up in my Studio file.

There are 27 occurrences in my file of strings
... See more
I have the following text in a string in an XML file I am processing with Studio 2014.

<DragType>
<DragText font="Tahoma" font-color="00ccff" font-size="11" startLeft="-2" startTop="352" targetLeft="134" targetTop="175" text="Baggage Fees" />
<DragType/>

text="Baggage Fees"

The text - Baggage Fees - needs to be translated but it does not show up in my Studio file.

There are 27 occurrences in my file of strings with text like this: text="Something to translate"

Any help to offer?

[Edited at 2014-04-24 21:41 GMT]

[Edited at 2014-04-24 21:43 GMT]

[Edited at 2014-04-25 14:23 GMT]

[Edited at 2014-04-25 14:25 GMT]
Collapse


 
RWS Community
RWS Community
United Kingdom
Local time: 03:10
English
Add a rule for the text attribute Apr 24, 2014

petercallen wrote:

text="Baggage Fees"



It's an attribute, and these are normally not translated. So the default AnyXML will not parse them for translation.

All you have to do is add a rule that parses the attribute. If you created a custom XML filetype based on your XML file then it's probably simple as you just select the element name, and then the attribute from the list offered. If you didn't then just add a new rule to the AnyXML filetype that is being used when you translate the file that is set to Always Translate and looks like this:

//elementname/@text

Replace the elementname with the actual name of the element that you didn't provide here and that ruloe will extract the text of the text attribute for translation.

Regards

Paul


 
petercallen
petercallen
United States
Local time: 20:10
TOPIC STARTER
I updated my post to show the code in my XML file. Apr 25, 2014

If I understand correctly, I need to create a new rule for the element DragType

//DragText/@text

It still does not show it in my translation table.


 
RWS Community
RWS Community
United Kingdom
Local time: 03:10
English
Did you... Apr 26, 2014

... add the rule and then open the XML again from scratch, or just add the rule to the existing filetype without reparsing it? Did you add the rule to the correct filetype? There are a few default XML filetypes in Studio... just one reason why it's better to always create your own filetypes for XML. Is this part of a Project and you made the changes in File -> Options rather than Project Settings? Did you make the rule Always Translatable?

If none of this really makes sense to y
... See more
... add the rule and then open the XML again from scratch, or just add the rule to the existing filetype without reparsing it? Did you add the rule to the correct filetype? There are a few default XML filetypes in Studio... just one reason why it's better to always create your own filetypes for XML. Is this part of a Project and you made the changes in File -> Options rather than Project Settings? Did you make the rule Always Translatable?

If none of this really makes sense to you please feel free to send me the XML file you have, and your custom XML settings file (if you created one), and I'll take a look. Certainly that rule should do the trick on the face of it and with the minimum information I know about your file.

I can then provide you with a better explanation on how to handle your file.

One other thing in the meantime... this article might help a little : http://wp.me/s2xDjK-xpath

Regards

Paul
[email protected]

[Edited at 2014-04-26 06:58 GMT]
Collapse


 
petercallen
petercallen
United States
Local time: 20:10
TOPIC STARTER
Victory! Apr 28, 2014

Thanks for your help!

 
vojtech-olsan
vojtech-olsan
Czech Republic
Another XML Parsing help needed Jan 13, 2015

Hi,
I have a similar problem with parsing. The file I got is not exactly XML but does have an internal structure which is like this:

< _[number] CID="[number]" English="[Translatable]" MaxWidth="[number]" Group="[Translatable]" Description="[Translatable]" / >


...about 700 lines of that.
I tried to make a new filetype and put the parsing like this: //_*/@English, //_*/@Group, //_*/@Description but Studio didn't load anything. The problem proba
... See more
Hi,
I have a similar problem with parsing. The file I got is not exactly XML but does have an internal structure which is like this:

< _[number] CID="[number]" English="[Translatable]" MaxWidth="[number]" Group="[Translatable]" Description="[Translatable]" / >


...about 700 lines of that.
I tried to make a new filetype and put the parsing like this: //_*/@English, //_*/@Group, //_*/@Description but Studio didn't load anything. The problem probably is that the tag name is different on every line.

Is there any way to get it in all at once?

I did manage to load it when I the actual number of the line, so it looked like //_0/*@English, but as there are about 700 and they are not in a sequence i would like to find a rule where the number can change.

Thank you very much for any advice...

Vojta


[Edited at 2015-01-13 08:41 GMT]

[Edited at 2015-01-13 09:14 GMT]
Collapse


 
RWS Community
RWS Community
United Kingdom
Local time: 03:10
English
I guess you could do... Jan 15, 2015

... something like these will do the trick maybe, based on the idea that you should only extract these attributes when "English" is in the string. So if you had multiple languages you could parse only the lines with "English" and ignore the rest:

//*/@English

//*[@English]/@Group

//*[@English]/@Description

If I concatenate these then this works too, but if you're good with XPath you can probably tidy this up a bit better!

//*/@Eng
... See more
... something like these will do the trick maybe, based on the idea that you should only extract these attributes when "English" is in the string. So if you had multiple languages you could parse only the lines with "English" and ignore the rest:

//*/@English

//*[@English]/@Group

//*[@English]/@Description

If I concatenate these then this works too, but if you're good with XPath you can probably tidy this up a bit better!

//*/@English|//*[@English]/@Group|//*[@English]/@Description

If this isn't what you needed perhaps it will give you an idea. It's tricky to do this based on one string alone, but my test file of this:


Returns this using this single rule:


So you can see the "French" was skipped and it didn't matter what numbers were in the elements as I ignored these altogether... based on your sample.

Hope this helps.

Regards

Paul
Collapse


 
vojtech-olsan
vojtech-olsan
Czech Republic
It works! Jan 15, 2015

Thank you very much Paul, you saved my day again, it works brilliantly.

Getting rid of the underscore at the beginning.. I should have tried that...

Thanks again,

Vojta


 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

XML Parsing Help needed







CafeTran Espresso
You've never met a CAT tool this clever!

Translate faster & easier, using a sophisticated CAT tool built by a translator / developer. Accept jobs from clients who use Trados, MemoQ, Wordfast & major CAT tools. Download and start using CafeTran Espresso -- for free

Buy now! »
Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »