<div dir="ltr">Hi,<div><br></div><div>Schematron is not only useful; it&#39;s fun. (I admit I am hard-core.)</div><div><br></div><div>Refactoring a little (but untested):</div><div><br></div><div><span style="font-family:arial,sans-serif;font-size:13px">&lt;let name=&quot;referencedImages&quot; value=&quot;$svgDocument//*:image/@*</span><span style="font-family:arial,sans-serif;font-size:13px">:href[not(</span><span style="font-family:arial,sans-serif;font-size:13px">starts-with(.,&#39;data&#39;)</span><span style="font-size:13px;font-family:arial,sans-serif">)]</span><span style="font-size:13px;font-family:arial,sans-serif">&quot;/&gt;</span></div>
<div><span style="font-size:13px;font-family:arial,sans-serif">&lt;let name=&quot;missingImages&quot; value=&quot;</span><span style="font-size:13px;font-family:arial,sans-serif">$referenced</span><span style="font-size:13px;font-family:arial,sans-serif">Images[not(exslt:exists(</span><span style="font-size:13px;font-family:arial,sans-serif">resolve-uri($t</span><span style="font-size:13px;font-family:arial,sans-serif">, base-uri($svgDocument)</span><span style="font-size:13px;font-family:arial,sans-serif">)))]</span><span style="font-size:13px;font-family:arial,sans-serif">&quot;/&gt;</span></div>
<div><span style="font-size:13px;font-family:arial,sans-serif">&lt;assert test=&quot;empty($missingImages)</span><span style="font-size:13px;font-family:arial,sans-serif">&quot;&gt;An image file referenced in SVG image &lt;value-of select=&quot;@href&quot;/&gt; is missing:</span></div>
<div><span style="font-size:13px;font-family:arial,sans-serif">  check for &lt;value-of select=&quot;string-join($missingImages,&#39;, &#39;)&quot;/&gt;&lt;/assert&gt;</span></div><div><span style="font-size:13px;font-family:arial,sans-serif"><br>
</span></div><div><span style="font-size:13px;font-family:arial,sans-serif">Thanks to Alex for doing the real work.</span></div><div><span style="font-size:13px;font-family:arial,sans-serif"><br></span></div><div><span style="font-size:13px;font-family:arial,sans-serif">Cheers, Wendell</span></div>
<div><br></div></div><div class="gmail_extra"><br clear="all"><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 10:35 AM, Alex Jitianu <span dir="ltr">&lt;<a href="mailto:alex_jitianu@sync.ro" target="_blank">alex_jitianu@sync.ro</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>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&#39;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&#39;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&#39;ve added the
      resolve-uri() function to compute the SVG document location.<br>
      <br>
      3. In the example below I&#39;ve changed a bit the assert XPath to
      ignore the href values that start with &#39;data&#39;. 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:<div class="im"><br>
      <br>
      &lt;schema <br>
          xmlns=<a href="http://purl.oclc.org/dsdl/schematron" target="_blank">&quot;http://purl.oclc.org/dsdl/schematron&quot;</a> <br>
          queryBinding=&quot;xslt2&quot;<br>
          xmlns:exslt=<a href="http://expath.org/ns/file" target="_blank">&quot;http://expath.org/ns/file&quot;</a>&gt;<br>
          &lt;ns uri=<a href="http://expath.org/ns/file" target="_blank">&quot;http://expath.org/ns/file&quot;</a> prefix=&quot;exslt&quot;/&gt;<br>
          &lt;pattern&gt;<br>
              &lt;rule context=&quot;image&quot;&gt;<br></div>
                  &lt;let name=&quot;svgDocument&quot;
      value=&quot;document(resolve-uri(@href, base-uri()))&quot; /&gt;<br>
                  &lt;let name=&quot;svgExists&quot;
      value=&quot;exists($svgDocument)&quot;/&gt;<br>
                  &lt;assert test=&quot;$svgExists&quot;&gt;The SVG file can&#39;t be
      loaded &lt;value-of select=&quot;resolve-uri(@href,
      base-uri())&quot;/&gt;&lt;/assert&gt;<br>
                  <br>
                  &lt;let name=&quot;realImages&quot;
      value=&quot;$svgDocument//*:image/@*:href&quot;/&gt;<br>
                  &lt;!-- If the SVG file can&#39;t be loaded or the SVG
      points to an embeded image SKIP IT. --&gt;<br>
                  &lt;let name=&quot;testImages&quot; value=&quot;for $realImage in
      $realImages return if (not($svgExists) or starts-with($realImage,
      &#39;data&#39;)) then true() else exslt:exists(resolve-uri($realImage,
      base-uri($svgDocument)))&quot;/&gt;<br>
                  &lt;assert test=&quot;empty(index-of($testImages,
      false()))&quot;&gt;The image file must exist&lt;/assert&gt;<div class="im"><br>
                  <br>
              &lt;/rule&gt;<br>
          &lt;/pattern&gt;<br>
      &lt;/schema&gt;<br>
      <br>
      Best regards,<br>
      Alex<br>
      <br></div><div><div class="h5">
      On 30-Jul-13 3:33 PM, KAATMAN Matthew wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      
      
      
      
      <div>
        <p class="MsoNormal"><span style="color:#1f497d">Hey Alex,<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">This looks
            really promising!<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">When I run
            validate with this schematron I get the following:<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">System ID:
            C:\svn\scripts\svgCheck.sch<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Engine name:
            ISO Schematron (XSLT 2.0)<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Severity: fatal<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Type: XML
            validation<u></u><u></u></span></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><u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></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><u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Engine name:
            ISO Schematron (XSLT 2.0)<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Severity: error<u></u><u></u></span></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<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Type: XML
            validation<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Even if I
            delete all SVG references, I receive the above two errors.<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></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.<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">System ID:
            C:\dita\en\products\simon\service\Attachments.dita<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Engine name:
            ISO Schematron (XSLT 2.0)<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Severity: error<u></u><u></u></span></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()
            (<a>&quot;data:image/jpeg;base64,/9j/4AA...&quot;</a>,
            <a>&quot;data:image/png;base64,iVBORw0K...&quot;</a>) <u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Type: XML
            validation<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></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”?<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></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!<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d">Thank you,<br>
            Matt<u></u><u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
        <p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></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:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext">From:</span></b><span style="font-size:10.0pt;font-family:&quot;Tahoma&quot;,&quot;sans-serif&quot;;color:windowtext">
                <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<u></u><u></u></span></p>
          </div>
        </div>
        <p class="MsoNormal"><u></u> <u></u></p>
        <div>
          <p class="MsoNormal">Hello  Matt,<br>
            <br>
            In Oxygen v15.0 we&#39;ve added in the &quot;Validate and check for
            Completeness&quot; dialog a new entry called &quot;Additional
            schematron checks&quot; in which you can specify additional
            Schematron checks that should be be executed on the topics.
            You can perform the check you&#39;ve described using a
            Schematron file with the following content:<br>
            <br>
            &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>
            &lt;schema <br>
                xmlns=<a href="http://purl.oclc.org/dsdl/schematron" target="_blank">&quot;http://purl.oclc.org/dsdl/schematron&quot;</a>
            <br>
                queryBinding=&quot;xslt2&quot;<br>
                xmlns:exslt=<a href="http://expath.org/ns/file" target="_blank">&quot;http://expath.org/ns/file&quot;</a>&gt;<br>
                &lt;ns uri=<a href="http://expath.org/ns/file" target="_blank">&quot;http://expath.org/ns/file&quot;</a>
            prefix=&quot;exslt&quot;/&gt;<br>
                &lt;pattern&gt;<br>
                    &lt;rule context=<a href="mailto:image[ends-with%28@href,%27.svg%27%29]" target="_blank">&quot;image[ends-with(@href,
              &#39;.svg&#39;)]&quot;</a>&gt;<br>
                        &lt;let name=&quot;svgDocument&quot;
            value=&quot;document(@href)&quot; /&gt;<br>
                        &lt;assert
            test=&quot;exslt:exists(resolve-uri($svgDocument//*:image/@*:href,
            base-uri($svgDocument)))&quot;&gt;<br>
                            The image file from the following SVG
            doesn&#39;t exist: &lt;value-of
            select=&quot;base-uri($svgDocument)&quot;/&gt;&lt;/assert&gt;<br>
                    &lt;/rule&gt;<br>
                &lt;/pattern&gt;<br>
            &lt;/schema&gt;<br>
            <br>
            Best regards,<br>
            Alex<br>
            -- <br>
            Alex Jitianu<br>
            &lt;oXygen/&gt;  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&#39;s not
            extremely crucial, but it would be helpful for us.<u></u><u></u></p>
          <p> <u></u><u></u></p>
          <p>I&#39;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&#39;t in our repository path.<u></u><u></u></p>
          <p> <u></u><u></u></p>
          <p>Within the SVG, I&#39;ll end up with
            something like:<u></u><u></u></p>
          <p>&lt;image width=&quot;1200&quot; height=&quot;1807&quot;
            xlink:href=&quot;../../../../../../../Users/Username/Pictures/PREVI
            PAV/PAV_printer_cover_open.jpg&quot;  &gt;<u></u><u></u></p>
          <p> <u></u><u></u></p>
          <p>When it should be:<u></u><u></u></p>
          <p>&lt;image width=&quot;1200&quot; height=&quot;1807&quot;
            xlink:href=&quot;images/PAV_printer_cover_open.jpg&quot;  &gt;<u></u><u></u></p>
          <p> <u></u><u></u></p>
          <p>Although, the validate/check for
            completeness wouldn&#39;t catch this on their workstation as the
            image exists and is valid, it would find it quickly on mine
            since it&#39;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&#39;t seem like the OT throws any
            errors either. The only way I find out is when I&#39;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 src="cid:part6.04030306.08000907@sync.ro" height="341" width="407" border="0"><u></u><u></u></p>
          <p> <u></u><u></u></p>
          <p>Thanks!<br>
            Matt<u></u><u></u></p>
          <p class="MsoNormal"><span>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&#39;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&#39;en prevenir l&#39;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>
              <br>
              <u></u><u></u></span></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"><span><u></u> <u></u></span></p>
      </div>
      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&#39;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&#39;en prevenir l&#39;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.
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
oXygen-user mailing list<br>
<a href="mailto:oXygen-user@oxygenxml.com">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><br>
<br></blockquote></div><br></div>