<div dir="ltr">Matt,<div><br></div><div>Oops, sorry about that $t, it was a relic of an earlier iteration. It should be . (dot).</div><div><br></div><div>I just started with Alex's code, reworked and reworked again. (Compulsive activity after a long day of XSLT/XQuery/XPath.) There is certain to be other tuning necessary for your case.</div>
<div><br></div><div>Cheers, Wendell</div><div><br></div><div><div class="gmail_extra"><div>Wendell Piez | <a href="http://www.wendellpiez.com" target="_blank">http://www.wendellpiez.com</a><br>XML | XSLT | electronic publishing<br>
Eat Your Vegetables<br>_____oo_________o_o___ooooo____ooooooo_^</div>
<br><br><div class="gmail_quote">On Tue, Jul 30, 2013 at 11:36 PM, KAATMAN Matthew <span dir="ltr"><<a href="mailto:matthew.kaatman@biomerieux.com" target="_blank">matthew.kaatman@biomerieux.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hey Wendell,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I am learning from all these examples. $t is undefined. Would you mind clarifying what it should be set to?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Thanks!<br>
Matt<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:oxygen-user-bounces@oxygenxml.com" target="_blank">oxygen-user-bounces@oxygenxml.com</a> [mailto:<a href="mailto:oxygen-user-bounces@oxygenxml.com" target="_blank">oxygen-user-bounces@oxygenxml.com</a>] <b>On Behalf Of </b>Wendell Piez<br>
<b>Sent:</b> Tuesday, July 30, 2013 6:20 PM</span></p><div><div class="h5"><br><b>To:</b> <a href="mailto:oxygen-user@oxygenxml.com" target="_blank">oxygen-user@oxygenxml.com</a><br><b>Subject:</b> Re: [oXygen-user] Feature request: Validation for linked images in SVG paths<u></u><u></u></div>
</div><p></p><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Hi,<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Schematron is not only useful; it's fun. (I admit I am hard-core.)<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Refactoring a little (but untested):<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><let name="referencedImages" value="$svgDocument//*:image/@*:href[not(starts-with(.,'data'))]"/></span><u></u><u></u></p>
</div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><let name="missingImages" value="$referencedImages[not(exslt:exists(resolve-uri($t, base-uri($svgDocument))))]"/></span><u></u><u></u></p>
</div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><assert test="empty($missingImages)">An image file referenced in SVG image <value-of select="@href"/> is missing:</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""> check for <value-of select="string-join($missingImages,', ')"/></assert></span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Thanks to Alex for doing the real work.</span><u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Cheers, Wendell</span><u></u><u></u></p></div><div><p class="MsoNormal">
<u></u> <u></u></p></div></div><div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><p class="MsoNormal">Wendell Piez | <a href="http://www.wendellpiez.com" target="_blank">http://www.wendellpiez.com</a><br>XML | XSLT | electronic publishing<br>
Eat Your Vegetables<br>_____oo_________o_o___ooooo____ooooooo_^<u></u><u></u></p></div><p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p><div><p class="MsoNormal">On Tue, Jul 30, 2013 at 10:35 AM, Alex Jitianu <<a href="mailto:alex_jitianu@sync.ro" target="_blank">alex_jitianu@sync.ro</a>> wrote:<u></u><u></u></p>
<div><div><p class="MsoNormal">Hello Matt,<br><br>1. The odd line is related to the fact that when validating with a Schematron file under the hood the Schematron is transformed in XSLT and that XSLT is applied on the document. The reported error line is inside that intermediate XSLT and unfortunately I don't think there is a round trip to get the real location in the Schematron file.<br>
<br>2. I believe the NullPointerException is a side effect of the fact that I didn't consider the fact that the SVG file is also referred relatively in the DITA document. As a result the SVG will not get located and parsed by the document() function and later on exists() function will break. In the example below I've added the resolve-uri() function to compute the SVG document location.<br>
<br>3. In the example below I've changed a bit the assert XPath to ignore the href values that start with 'data'. You should also take into account the fact that the SVG can contain multiple image elements. Perhaps you could assert it more elegantly than this but here a possible solution:<u></u><u></u></p>
<div><p class="MsoNormal"><br><br><schema <br> xmlns=<a href="http://purl.oclc.org/dsdl/schematron" target="_blank">"http://purl.oclc.org/dsdl/schematron"</a> <br> queryBinding="xslt2"<br> xmlns:exslt=<a href="http://expath.org/ns/file" target="_blank">"http://expath.org/ns/file"</a>><br>
<ns uri=<a href="http://expath.org/ns/file" target="_blank">"http://expath.org/ns/file"</a> prefix="exslt"/><br> <pattern><br> <rule context="image"><u></u><u></u></p>
</div><p class="MsoNormal"> <let name="svgDocument" value="document(resolve-uri(@href, base-uri()))" /><br> <let name="svgExists" value="exists($svgDocument)"/><br>
<assert test="$svgExists">The SVG file can't be loaded <value-of select="resolve-uri(@href, base-uri())"/></assert><br> <br> <let name="realImages" value="$svgDocument//*:image/@*:href"/><br>
<!-- If the SVG file can't be loaded or the SVG points to an embeded image SKIP IT. --><br> <let name="testImages" value="for $realImage in $realImages return if (not($svgExists) or starts-with($realImage, 'data')) then true() else exslt:exists(resolve-uri($realImage, base-uri($svgDocument)))"/><br>
<assert test="empty(index-of($testImages, false()))">The image file must exist</assert><u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt"><br> <br> </rule><br>
</pattern><br></schema><br><br>Best regards,<br>Alex<u></u><u></u></p></div><div><div><p class="MsoNormal">On 30-Jul-13 3:33 PM, KAATMAN Matthew wrote:<u></u><u></u></p></div></div></div><div><div><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div><p class="MsoNormal"><span style="color:#1f497d">Hey Alex,</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">This looks really promising!</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">When I run validate with this schematron I get the following:</span><u></u><u></u></p><p class="MsoNormal">
<span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">System ID: C:\svn\scripts\svgCheck.sch</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Engine name: ISO Schematron (XSLT 2.0)</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">Severity: fatal</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Type: XML validation</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Start location: 149:0 <span style="background:yellow">(Odd because the schematron is only 14 lines)</span></span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">System ID: C:\dita\pt\products\vitek2systems\pi\Appendix_A.dita <span style="background:yellow">(This is the first file with an SVG for the document I checked.)</span></span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">Engine name: ISO Schematron (XSLT 2.0)</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Severity: error</span><u></u><u></u></p><p class="MsoNormal">
<span style="color:#1f497d">Description: Exception thrown by extension function {public static boolean com.saxonica.functions.extfn.EXPathFile.exists(java.lang.String)}: java.lang.NullPointerException</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">Type: XML validation</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Even if I delete all SVG references, I receive the above two errors.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">I then tried it on a map with more SVGs and some that were verified to be broken. It is properly detecting the errors but I see false positives when the SVG contains embedded images instead of linked. I believe it’s trying to verify the binary data as the uri.</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">System ID: C:\dita\en\products\simon\service\Attachments.dita</span><u></u><u></u></p><p class="MsoNormal">
<span style="color:#1f497d">Engine name: ISO Schematron (XSLT 2.0)</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Severity: error</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Description: A sequence of more than one item is not allowed as the first argument of resolve-uri() ("data:image/jpeg;base64,/9j/4AA...", "data:image/png;base64,iVBORw0K...") </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d">Type: XML validation</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Is there a way for me to adjust the schematron to ignore href values that start with “data”?</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">I had previously attended a webinar Oxygen presented on schematron. I’m finally starting to understand how powerful it can be!</span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d">Thank you,<br>Matt</span><u></u><u></u></p><p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"> </span><u></u><u></u></p><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:oxygen-user-bounces@oxygenxml.com" target="_blank">oxygen-user-bounces@oxygenxml.com</a> [<a href="mailto:oxygen-user-bounces@oxygenxml.com" target="_blank">mailto:oxygen-user-bounces@oxygenxml.com</a>] <b>On Behalf Of </b>Alex Jitianu<br>
<b>Sent:</b> Tuesday, July 30, 2013 2:25 AM<br><b>To:</b> <a href="mailto:oxygen-user@oxygenxml.com" target="_blank">oxygen-user@oxygenxml.com</a><br><b>Subject:</b> Re: [oXygen-user] Feature request: Validation for linked images in SVG paths</span><u></u><u></u></p>
</div></div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">Hello Matt,<br><br>In Oxygen v15.0 we've added in the "Validate and check for Completeness" dialog a new entry called "Additional schematron checks" in which you can specify additional Schematron checks that should be be executed on the topics. You can perform the check you've described using a Schematron file with the following content:<br>
<br><?xml version="1.0" encoding="UTF-8"?><br><schema <br> xmlns=<a href="http://purl.oclc.org/dsdl/schematron" target="_blank">"http://purl.oclc.org/dsdl/schematron"</a> <br> queryBinding="xslt2"<br>
xmlns:exslt=<a href="http://expath.org/ns/file" target="_blank">"http://expath.org/ns/file"</a>><br> <ns uri=<a href="http://expath.org/ns/file" target="_blank">"http://expath.org/ns/file"</a> prefix="exslt"/><br>
<pattern><br> <rule context=<a href="mailto:image[ends-with%28@href,%27.svg%27%29]" target="_blank">"image[ends-with(@href, '.svg')]"</a>><br> <let name="svgDocument" value="document(@href)" /><br>
<assert test="exslt:exists(resolve-uri($svgDocument//*:image/@*:href, base-uri($svgDocument)))"><br> The image file from the following SVG doesn't exist: <value-of select="base-uri($svgDocument)"/></assert><br>
</rule><br> </pattern><br></schema><br><br>Best regards,<br>Alex<br>-- <br>Alex Jitianu<br><oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger<br><a href="http://www.oxygenxml.com" target="_blank">http://www.oxygenxml.com</a><br>
<br><br>On 29-Jul-13 9:38 PM, KAATMAN Matthew wrote:<u></u><u></u></p></div><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt"><p>Hey Guys,<u></u><u></u></p><p> <u></u><u></u></p><p>This is a feature request that's not extremely crucial, but it would be helpful for us.<u></u><u></u></p>
<p> <u></u><u></u></p><p>I'm having our authors create SVG overlays and link to the background image (jpeg or png).<u></u><u></u></p><p> <u></u><u></u></p><p>Sometimes they accidentally link to an image that isn't in our repository path.<u></u><u></u></p>
<p> <u></u><u></u></p><p>Within the SVG, I'll end up with something like:<u></u><u></u></p><p><image width="1200" height="1807" xlink:href="../../../../../../../Users/Username/Pictures/PREVI PAV/PAV_printer_cover_open.jpg" ><u></u><u></u></p>
<p> <u></u><u></u></p><p>When it should be:<u></u><u></u></p><p><image width="1200" height="1807" xlink:href="images/PAV_printer_cover_open.jpg" ><u></u><u></u></p><p> <u></u><u></u></p>
<p>Although, the validate/check for completeness wouldn't catch this on their workstation as the image exists and is valid, it would find it quickly on mine since it's outside the path that gets checked in and I’d be missing that image.<u></u><u></u></p>
<p> <u></u><u></u></p><p>It doesn't seem like the OT throws any errors either. The only way I find out is when I'm viewing the PDF and notice that antenna house has substituted a broken image.<u></u><u></u></p><p>
<u></u><u></u></p><p>Example:<u></u><u></u></p><p><img border="0" width="407" height="341"><u></u><u></u></p><p> <u></u><u></u></p><p>Thanks!<br>Matt<u></u><u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt">AVIS : Ce courrier et ses pieces jointes sont destines a leur seul destinataire et peuvent contenir des informations confidentielles appartenant a bioMerieux. Si vous n'etes pas destinataire, vous etes informe que toute lecture, divulgation, ou reproduction de ce message et des pieces jointes est strictement interdite. Si vous avez recu ce message par erreur merci d'en prevenir l'expediteur et de le detruire, ainsi que ses pieces jointes. NOTICE: This message and attachments are intended only for the use of their addressee and may contain confidential information belonging to bioMerieux. If you are not the intended recipient, you are hereby notified that any reading, dissemination, distribution, or copying of this message, or any attachment, is strictly prohibited. If you have received this message in error, please notify the original sender immediately and delete this message, along with any attachments. <br>
<br><u></u><u></u></p><pre>_______________________________________________<u></u><u></u></pre><pre>oXygen-user mailing list<u></u><u></u></pre><pre><a href="mailto:oXygen-user@oxygenxml.com" target="_blank">oXygen-user@oxygenxml.com</a><u></u><u></u></pre>
<pre><a href="http://www.oxygenxml.com/mailman/listinfo/oxygen-user" target="_blank">http://www.oxygenxml.com/mailman/listinfo/oxygen-user</a><u></u><u></u></pre></blockquote><p class="MsoNormal"> <u></u><u></u></p></div>
<p class="MsoNormal">AVIS : Ce courrier et ses pieces jointes sont destines a leur seul destinataire et peuvent contenir des informations confidentielles appartenant a bioMerieux. Si vous n'etes pas destinataire, vous etes informe que toute lecture, divulgation, ou reproduction de ce message et des pieces jointes est strictement interdite. Si vous avez recu ce message par erreur merci d'en prevenir l'expediteur et de le detruire, ainsi que ses pieces jointes. NOTICE: This message and attachments are intended only for the use of their addressee and may contain confidential information belonging to bioMerieux. If you are not the intended recipient, you are hereby notified that any reading, dissemination, distribution, or copying of this message, or any attachment, is strictly prohibited. If you have received this message in error, please notify the original sender immediately and delete this message, along with any attachments. <u></u><u></u></p>
</blockquote><p class="MsoNormal"><u></u> <u></u></p></div></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>_______________________________________________<br>oXygen-user mailing list<br><a href="mailto:oXygen-user@oxygenxml.com" target="_blank">oXygen-user@oxygenxml.com</a><br>
<a href="http://www.oxygenxml.com/mailman/listinfo/oxygen-user" target="_blank">http://www.oxygenxml.com/mailman/listinfo/oxygen-user</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div>
<div><div class="h5">AVIS : Ce courrier et ses pieces jointes sont destines a leur seul destinataire et peuvent contenir des informations confidentielles appartenant a bioMerieux. Si vous n'etes pas destinataire, vous etes informe que toute lecture, divulgation, ou reproduction de ce message et des pieces jointes est strictement interdite. Si vous avez recu ce message par erreur merci d'en prevenir l'expediteur et de le detruire, ainsi que ses pieces jointes.
NOTICE: This message and attachments are intended only for the use of their addressee and may contain confidential information belonging to bioMerieux. If you are not the intended recipient, you are hereby notified that any reading, dissemination, distribution, or copying of this message, or any attachment, is strictly prohibited. If you have received this message in error, please notify the original sender immediately and delete this message, along with any attachments.
</div></div></div></blockquote></div><br></div></div></div>