Loading ...
Sorry, an error occurred while loading the content.

Re: [rng-users] Schema with

Expand Messages
  • Jirka Kosek
    ... Schematron validation is pretty easy in PHP as you can transform Schematron in XSLT (and sorry for Czech comments, but OP will understood):
    Message 1 of 7 , May 14, 2013
    • 0 Attachment
      On 14.5.2013 12:04, Miloslav Hůla wrote:

      > I'm doing validation in PHP where support of Schematron is poor and
      > difficult. I'll do additional validation on higher level.

      Schematron validation is pretty easy in PHP as you can transform
      Schematron in XSLT (and sorry for Czech comments, but OP will understood):

      <?php
      Header("Content-type: text/plain; charset=utf-8");

      // načtení schématu
      $sch = DOMDocument::load("../schema/zamestnanci.sch");

      // načtení stylu pro převod Schematronu na XSLT
      $sch2xslt = DOMDocument::load("../tools/skeleton1-5.xsl");

      // vytvoření procesoru XSLT
      $proc = new xsltprocessor();
      $proc->importStylesheet($sch2xslt);

      // vytvoření XSLT stylu implementujícího schematronové kontroly
      $validator = $proc->transformToDoc($sch);

      // načtení dokumentu k validaci
      $doc = DOMDocument::load("../schema/zamestnanci-chyba.xml",
      LIBXML_NOENT|LIBXML_DTDLOAD|LIBXML_DTDATTR);

      // nastavení validátoru jako stylu na procesoru XSLT
      $proc->importStylesheet($validator);

      // validace oproti Schematronu
      $vysledek = $proc->transformToDoc($doc);

      // zjištění a případné vypsání chyb
      if ($vysledek->textContent == "")
      {
      echo "Dokument je validní oproti Schematronu.";
      }
      else
      {
      echo "Dokument není validní.\n";
      echo $vysledek->textContent;
      }

      ?>

      --
      ------------------------------------------------------------------
      Jirka Kosek e-mail: jirka@... http://xmlguru.cz
      ------------------------------------------------------------------
      Professional XML consulting and training services
      DocBook customization, custom XSLT/XSL-FO document processing
      ------------------------------------------------------------------
      OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
      ------------------------------------------------------------------
      Bringing you XML Prague conference http://xmlprague.cz
      ------------------------------------------------------------------
    • Miloslav Hůla
      ... I was reading about that in your book. But it is not so straightforward like $doc- relaxNGValidate(). Seems to me, it is about XSLT support. Even if it
      Message 2 of 7 , May 14, 2013
      • 0 Attachment
        >> I'm doing validation in PHP where support of Schematron is poor and
        >> difficult. I'll do additional validation on higher level.
        >
        > Schematron validation is pretty easy in PHP as you can transform
        > Schematron in XSLT.

        I was reading about that in your book. But it is not so straightforward
        like $doc->relaxNGValidate(). Seems to me, it is about XSLT support.

        Even if it works well, it brings new dependency on XSL PHP extension and
        adds memory stress. Due to that, I cannot use it in my app.

        Is there any way, how to validate by Relax NG containing Schematron? Or
        I must extract Schematron namespace and do it as you wrote?

        Thank you, Miloslav
      • Jirka Kosek
        ... There are some Java libraries supporting embeded Schematron in RELAX NG, but with PHP you have to extract Schematron into separate schema, then create
        Message 3 of 7 , May 14, 2013
        • 0 Attachment
          On 14.5.2013 16:39, Miloslav Hůla wrote:

          > Is there any way, how to validate by Relax NG containing Schematron? Or
          > I must extract Schematron namespace and do it as you wrote?

          There are some Java libraries supporting embeded Schematron in RELAX NG,
          but with PHP you have to extract Schematron into separate schema, then
          create transformation from it using Schematron skeleton and then run
          this transformation for validation.

          Jirka

          --
          ------------------------------------------------------------------
          Jirka Kosek e-mail: jirka@... http://xmlguru.cz
          ------------------------------------------------------------------
          Professional XML consulting and training services
          DocBook customization, custom XSLT/XSL-FO document processing
          ------------------------------------------------------------------
          OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
          ------------------------------------------------------------------
          Bringing you XML Prague conference http://xmlprague.cz
          ------------------------------------------------------------------
        Your message has been successfully submitted and would be delivered to recipients shortly.