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

Schema with

Expand Messages
  • miloslav.hula
    Dear all, I m writing Relax NG to check following XML: a b c There can be a lot of
    Message 1 of 7 , May 13, 2013
    • 0 Attachment
      Dear all,

      I'm writing Relax NG to check following XML:
      <params>
      <param>a</param>
      <param>b</param>
      <param>c</param>
      </params>

      There can be a lot of <param> elements in any order. Some of them are required, others are optional.

      I'm trying to express, that <param>a</param> and <param>b</param> are required by following schema (here without grammar and start):
      <element name="params">
      <interleave>
      <element name="param"><value>a</value></element>
      <element name="param"><value>b</value></element>
      <zeroOrMore>
      <element name="param"><text /></element>
      </zeroOrMore>
      </interleave>
      </element>

      I get same three errors: 'Element or text conflicts in interleave'. I feel that is something about <interleave> limitations, but I cannot find why and understand it.

      Could you please someone explain it to me and helps me find a solution?

      Thank you in advance, Miloslav
    • Gerben Abbink
      When i try your RelaxNG schema in XMLBlueprint i get a different error: [Jing 2009] Relax NG Schema [Untitled-1].rng is not valid. Description: [Jing 2009] the
      Message 2 of 7 , May 13, 2013
      • 0 Attachment
        When i try your RelaxNG schema in XMLBlueprint i get a different error:

        [Jing 2009] Relax NG Schema [Untitled-1].rng is not valid.

        Description: [Jing 2009] the element "param" can occur in more than one operand of "interleave"
        File: [Untitled-1].rng (7:26)

        Gerben


        On Mon, May 13, 2013 at 10:18 PM, miloslav.hula <miloslav.hula@...> wrote:
         

        Dear all,

        I'm writing Relax NG to check following XML:
        <params>
        <param>a</param>
        <param>b</param>
        <param>c</param>
        </params>

        There can be a lot of <param> elements in any order. Some of them are required, others are optional.

        I'm trying to express, that <param>a</param> and <param>b</param> are required by following schema (here without grammar and start):
        <element name="params">
        <interleave>
        <element name="param"><value>a</value></element>
        <element name="param"><value>b</value></element>
        <zeroOrMore>
        <element name="param"><text /></element>
        </zeroOrMore>
        </interleave>
        </element>

        I get same three errors: 'Element or text conflicts in interleave'. I feel that is something about <interleave> limitations, but I cannot find why and understand it.

        Could you please someone explain it to me and helps me find a solution?

        Thank you in advance, Miloslav


      • George Cristian Bina
        Hi Miloslav, Please see https://www.oasis-open.org/committees/relax-ng/spec-20011203.html#interleave-restrictions This restriction basically say that you
        Message 3 of 7 , May 14, 2013
        • 0 Attachment
          Hi Miloslav,

          Please see
          https://www.oasis-open.org/committees/relax-ng/spec-20011203.html#interleave-restrictions

          This restriction basically say that you cannot interleave two (or more)
          elements with the same name, param in your case.

          I cannot think of a way to obtain what you want in Relax NG.
          As options you have
          - set an order on your parameters, add the required parameters first
          and then the optional ones, similar with your model if you delete the
          interleave tags.
          - use a more relaxed model in Relax NG and then use Schematron or some
          other mechanism to enforce your additional constraints. Schematron can
          be also embedded in Relax NG.

          Best Regards,
          George
          --
          George Cristian Bina
          <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
          http://www.oxygenxml.com

          On 5/13/13 11:18 PM, miloslav.hula wrote:
          > Dear all,
          >
          > I'm writing Relax NG to check following XML:
          > <params>
          > <param>a</param>
          > <param>b</param>
          > <param>c</param>
          > </params>
          >
          > There can be a lot of <param> elements in any order. Some of them are required, others are optional.
          >
          > I'm trying to express, that <param>a</param> and <param>b</param> are required by following schema (here without grammar and start):
          > <element name="params">
          > <interleave>
          > <element name="param"><value>a</value></element>
          > <element name="param"><value>b</value></element>
          > <zeroOrMore>
          > <element name="param"><text /></element>
          > </zeroOrMore>
          > </interleave>
          > </element>
          >
          > I get same three errors: 'Element or text conflicts in interleave'. I feel that is something about <interleave> limitations, but I cannot find why and understand it.
          >
          > Could you please someone explain it to me and helps me find a solution?
          >
          > Thank you in advance, Miloslav
          >
          >
          >
          > ------------------------------------
          >
          > Yahoo! Groups Links
          >
          >
          >
        • Miloslav Hůla
          Hi George, I was thinking, that linked statement talks only about mutual referencing by . Thank you for explanation. I m doing validation in PHP where
          Message 4 of 7 , May 14, 2013
          • 0 Attachment
            Hi George,

            I was thinking, that linked statement talks only about mutual
            referencing by <ref>. Thank you for explanation.

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

            Thak you, regards, Miloslav

            Dne 14.5.2013 10:50, George Cristian Bina napsal(a):
            > Hi Miloslav,
            >
            > Please see
            > https://www.oasis-open.org/committees/relax-ng/spec-20011203.html#interleave-restrictions
            >
            >
            > This restriction basically say that you cannot interleave two (or more)
            > elements with the same name, param in your case.
            >
            > I cannot think of a way to obtain what you want in Relax NG.
            > As options you have
            > - set an order on your parameters, add the required parameters first
            > and then the optional ones, similar with your model if you delete the
            > interleave tags.
            > - use a more relaxed model in Relax NG and then use Schematron or some
            > other mechanism to enforce your additional constraints. Schematron can
            > be also embedded in Relax NG.
            >
            >> I'm writing Relax NG to check following XML:
            >> <params>
            >> <param>a</param>
            >> <param>b</param>
            >> <param>c</param>
            >> </params>
            >>
            >> There can be a lot of <param> elements in any order. Some of them are
            >> required, others are optional.
            >>
            >> I'm trying to express, that <param>a</param> and <param>b</param> are
            >> required by following schema (here without grammar and start):
            >> <element name="params">
            >> <interleave>
            >> <element name="param"><value>a</value></element>
            >> <element name="param"><value>b</value></element>
            >> <zeroOrMore>
            >> <element name="param"><text /></element>
            >> </zeroOrMore>
            >> </interleave>
            >> </element>
            >>
            >> I get same three errors: 'Element or text conflicts in interleave'. I
            >> feel that is something about <interleave> limitations, but I cannot
            >> find why and understand it.
            >>
            >> Could you please someone explain it to me and helps me find a solution?
            >>
            >> Thank you in advance, Miloslav
          • 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 5 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 6 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 7 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.