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

Arbitrary content of element

Expand Messages
  • antonin_karolik
    Hello, I am RelaxNG newbie. I have tried to solve following problem but I havn t find any solution. Does anybody know how can I use just one element with
    Message 1 of 4 , Jan 5, 2007
    • 0 Attachment
      Hello,

      I am RelaxNG newbie. I have tried to solve following problem but I
      havn't find any solution.

      Does anybody know how can I use just one element with arbitrary
      content (with atbitrary sequence of other elements). In my XML I have
      one element which can consists of unimportant data (elements/
      attributes). Unfortunately the structure of this element can be very
      rich but there is no need to validate it.

      Is there any way how to turn off the validation for this element?

      Simple example of my XML can be:

      <root>
      <important_element>important data</important_element>
      <unimportant_ element>
      unimportant rich XML structrure
      </unimportant_element>
      </root>

      Thank you for any answer

      AertonSena
    • G. Ken Holman
      ... I usually create a pattern that I name any that allows any element with any attributes mixed with text and use that. Note the running example below where
      Message 2 of 4 , Jan 5, 2007
      • 0 Attachment
        At 2007-01-05 15:26 +0000, antonin_karolik wrote:
        >Does anybody know how can I use just one element with arbitrary
        >content (with atbitrary sequence of other elements).

        I usually create a pattern that I name "any" that allows any element
        with any attributes mixed with text and use that.

        Note the running example below where I modify your instance to first
        be invalid, validate it with errors, then in another window I edit it
        to be valid, then validate it without errors.

        I hope this helps.

        . . . . . . . . Ken

        T:\ftemp>type antonin.rnc
        start = element root { important_element, unimportant_element }

        important_element = element important_element { text }

        unimportant_element = any

        any = ( element * { attribute * { text }*, any } | text )*
        T:\ftemp>type antonin.xml
        <root>
        <important_element>important <rich/> data</important_element>
        <unimportant_element>
        unimportant <rich/> XML <structrure/>
        </unimportant_element>
        </root>

        T:\ftemp>rnc antonin.rnc antonin.xml
        T:\ftemp\antonin.xml:2: error: element "rich" not allowed in this context

        T:\ftemp>type antonin.xml
        <root>
        <important_element>important data</important_element>
        <unimportant_element>
        unimportant <rich/> XML <structrure/>
        </unimportant_element>
        </root>

        T:\ftemp>rnc antonin.rnc antonin.xml

        T:\ftemp>

        --
        World-wide corporate, govt. & user group XML, XSL and UBL training
        RSS feeds: publicly-available developer resources and training
        G. Ken Holman mailto:gkholman@...
        Crane Softwrights Ltd. http://www.CraneSoftwrights.com/r/
        Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
        Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/r/bc
        Legal business disclaimers: http://www.CraneSoftwrights.com/legal
      • Syd Bauman
        ... The following simple schema demonstrates use of a wildcard, which I think is what you want to use. It is based on the one in Eric van der Vlist s book
        Message 3 of 4 , Jan 5, 2007
        • 0 Attachment
          > Does anybody know how can I use just one element with arbitrary
          > content (with atbitrary sequence of other elements).

          The following simple schema demonstrates use of a wildcard, which I
          think is what you want to use. It is based on the one in Eric van der
          Vlist's book _Relax NG_.

          any = ( element * { any* } | attribute * { text }* | text )
          start = element unimportant { any* }
        • antonin_karolik
          Thanks all for your answers. This works fine! ;-] Best regards Aertonsena
          Message 4 of 4 , Jan 5, 2007
          • 0 Attachment
            Thanks all for your answers. This works fine! ;-]

            Best regards

            Aertonsena
          Your message has been successfully submitted and would be delivered to recipients shortly.