Not Considering

Better XPath expression support/assistance - Full W3C conformity – Random output

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&amp;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

  • You may have overlooked my suggestions to include a RegexBuddy-like feature? What about a Tell me enhancement? Advanced display/preview? To use an analogy here: All roads lead to Rome, but I want to know the fastest/smoothest/most convenient way (myself). Even if I'm not a tour guide (i.e. XPath expert) Wink! Does this make more sense to you?

  • And what do you suggest?  You are incorrect about the lack of W3C standard support as it does provide this already.  It doesn't support XPath 2.0 and this would be a nice enhancement, but can comment on whether this is seen as important or not.

    "I could make it work, too. "

    Then why did you say it didn't work?

    I think, that if you have a good idea for how this could be simplified then you should post that.  But this post is not only incorrect but there isn't an idea in there either.

  • Thanks for your feedback, Paul! Seems like you are an expert on this fieldStarStarStarStarStar! The output is exactly what I was referring toThumbsup
    It's not so much of making it work. Non-sensical, however, necessary, user-friendly settings still workWink. I could make it work, too. 
    The way of getting there is not really transparent, easy and well-assisted. Could we make it more transparent and easier?

  • that works perfectly well for me:

    Maybe something else is wrong with your filetype settings?

    However, this makes no sense as it's very unclear:

    "What would be the correct XPath expression to translate Elements (<Shape>) that have an attribute (<type="Rectangle">) but not (<type="Image")?"

    You are not allowed to have attributes with the same name (type) twice in the same start tag,  So this requirement is non-sensical.