Hi!
Trying to configure a file type using XPath expression, the process to find the right expression is not (always) easy. W3C standards should apply in Studio https://www.w3schools.com/xml/xpath_syntax.asp (SDL Support confirmed).
Code sample:
<?xml version="1.0" encoding="utf-8"?>
<fileProperties>
<ImageOverlay Profile="Sample path" ProfileHash="0815" ScreenRectangle="1282,439,170,184">
<OriginalImage AutoAdjust="true" Type="Image" ShapeTimeSpan="10000" EnableCropRectangle="false" CropRectangle="0,0,274,162" ComputedWidth="410" ComputedHeight="442" Format="tiff" EnableGrayScaleFormat="false" ConditionTagExpression="" ExportFormat="png">Sample pic</OriginalImage>
<Shapes>
<Shape Type="Image" X="203" Y="-3" Width="197" Height="188" Format="jpg" Source="file:///C:/Users/hmoshoevel/Documents/My Projects/Images_raw/GLB_CAM/Illustration_tooth&bars.jpg" Date="2016-09-28T15:43:11.5358216+02:00" SourceHash="8f7c5a4e4f8d49df76df2fb54554f9975195e5f4" ShapeTimeSpan="10000" Right="66" Bottom="190" Left="254" Top="192" Rotation="0">Another sample pic</Shape>
<Shape Type="Rectangle" PaddingLeft="5" PaddingBottom="0" PaddingRight="5" PaddingTop="0" X="106" Y="233" Width="218" Height="53" ShapeTimeSpan="10000" Right="86" Bottom="4" LineColor="#de7d00" LineWidth="4" BackgroundType="Solid" BackgroundColor="#ffffff" Transparency="0" FontFamily="Stone Sans II ITC Com Md Cn" FontSize="13" Color="#000000" Left="106" Top="246">Bars</Shape>
<Shape Type="Polyline" Coordinates="214,233,214,214,54,214,24,88" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Polyline" Coordinates="214,214,112,156" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Polyline" Coordinates="214,214,240,71" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Polyline" Coordinates="214,214,257,186,304,153" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Polyline" Coordinates="214,214,352,214,362,71" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Polyline" Coordinates="214,213,146,92" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Rectangle" PaddingLeft="5" PaddingBottom="0" PaddingRight="5" PaddingTop="0" X="115" Y="-70" Width="174" Height="49" ShapeTimeSpan="10000" Right="121" Bottom="317" LineColor="#de7d00" LineWidth="4" BackgroundType="Solid" BackgroundColor="#ffffff" Transparency="0" FontFamily="Stone Sans II ITC Com Md Cn" FontSize="13" Color="#000000" Left="115" Top="1">Workspace</Shape>
<Shape Type="Polyline" Coordinates="202,-21,102,28" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Polyline" Coordinates="201,-20,296,23" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Rectangle" PaddingLeft="5" PaddingBottom="0" PaddingRight="5" PaddingTop="0" X="115" Y="-136" Width="174" Height="57" ShapeTimeSpan="10000" Right="121" Bottom="375" LineColor="#de7d00" LineWidth="4" BackgroundType="Solid" BackgroundColor="#ffffff" Transparency="0" FontFamily="Stone Sans II ITC Com Md Cn" FontSize="13" Color="#000000" Left="115" Top="7">Workspace border</Shape>
<Shape Type="Polyline" Coordinates="115,-108,89,-108,89,10" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
<Shape Type="Polyline" Coordinates="290,-108,309,-108,310,4" ShapeTimeSpan="10000" LineWidth="3" LineColor="#de7d00" PaddingLeft="0" PaddingRight="0" PaddingTop="0" PaddingBottom="0" />
</Shapes>
<Variables />
<Shapes IsResourceLayer="true" Name="Resources" />
<ConditionTagSet />
</ImageOverlay>
</fileProperties>
E.g. What would be the correct XPath expression to translate Elements (<Shape>) that have an attribute (<type="Rectangle">) but not (<type="Image")?
The following did not work (although fine with W3 standards):
E.g.
//Shapes/Shape[@Type='Rectangle'] (translatable)
Eventually, I made it work by using:
//*[@Type = 'Image'] (not translatable)
which only gives me 3 elements to translate.
Could something more be included in the Studio help/SDL Community https://community.sdl.com/product-groups/translationproductivity/f/regex_and_xpath? How about extending Tell me functionality? Or something like https://www.regexbuddy.com/ to give you better indication what are doing is supported?
By default all text elements are extracted by Studio even if you do not define them in the parser rule.
The process and guidance is cumbersome/poor and needs to be reviewed, since this can be very powerful/useful at times. Especially when it's more user-friendly.
Thanks for your review!
Best regards,
Manuel