Detecting language please wait for.......
I'm trying to create a custom XML file type to extract part of an XML attribute value. To make things a bit more complicated, the attribute value is actually an XPath too.
Suppose this XML file:
<root><Attribute XPath="//Buttons[@Display='Name']" /></root>
I want to translate only Name.
It's easy enough to extract the entire attribute value. Just add //Attribute/@XPath to the parser, and the editor will show //Buttons[@Display='Name'].
I was trying to get rid of the irrelevant section by means of the embedded content processor:* Document structure information: Tag (x-tm-tag)* Tag definition rules** Start Tag Expression: \/\/Buttons\[@Display='** End Tag Expression: '\]
However, I still get the entire attribute value. I can't get the embedded content processor to work... I also tried easier tag definition rules, but it doesn't kick in.
Or am I on the wrong track and should I try thing with a more advanced parser rule?
Any advice would be greatly appreciated!
Ken De Wachter said:Document structure information: Tag (x-tm-tag)
This part is incorrect. The "Tag" here means something completely different.
What you need to put here is what you have specified in your parser rule.E.g. in my example I have specified that the parser rule extracts an "Element", so this is what I need to specify in the Embedded Content Processor:
Thanks, that makes sense. I tried it and it works for elements.
However, there it does not work for attributes:
I specify the context information for attribute values as Element:
Yet it still appears as a tag in the editor:
Just to be on the safe side, I added Element (sdl:element) and Tag (x-tm-tag) to the Document structure information of the Embedded content processor.
Ken De Wachter
I think your problem is that embedded content is not supported for attributes.
Your best bet is to post-process the file, perhaps using something like the SDL Data Protection Suite, or Clean up Tasks from the appstore.
So simply use "Custom" when defining your parser rule and define your own values. And then use the "Identifier" you define there in the Embedded Content Processor settings.
EDIT:Paul is right, I keep forgetting that for some weird and unknown reason attribute values cannot be passed to Embedded Content Processor.Why? That's a mystery... Embedded Content Processor shouldn't absolutely care about the source of the string being passed into it... it should be just a string, nothing else, no matter what's its origin... a string should be a string...
That's a pity... What was the logic for not supporting embedded content in attribute values?
Do you think it's doable using a parser rule? I tried using substring-after, but I can't get it to work properly (I haven't even tried to fix the apostrophes in the attribute value yet...):
This parser rule doesn't give any result in Studio, though it works in XPath validators: substring-after(//Attribute/@XPath,'Display=')
I also considered the SDL Data Protection Suite, but I want to avoid running the batch task separately. If I include the Protect batch task in a task sequence (Prepare and Protect), it works great. The tags aren't even visible in the editor! However, I can't unprotect anymore so the content disappears from my target file... I guess this relates to one of my earlier questions (https://community.sdl.com/product-groups/translationproductivity/f/openexchange_applications/20645/bug-in-when-executing-protect-batch-task-in-task-sequence---sdl-data-protection-suite-project-anonymizer). Some great advances have been made, but we're not there yet (c: