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

Factor out name class declaration?

Expand Messages
  • john.madden58
    I hope somebody can help me. In a big RNG project that contains many files, I repeatedly use a particular name-class in various places throughout the project.
    Message 1 of 9 , Dec 8, 2008
    • 0 Attachment
      I hope somebody can help me. In a big RNG project that contains many files, I repeatedly
      use a particular name-class in various places throughout the project. (It's the name class
      of all names that are not in any of the namespaces used by my project, i.e. the foreign
      name class with respect to my project's namespaces.)

      <anyName>
      <except>
      <nsName ns="http://myproject.org/ns1/"/>
      <nsName ns="http://myproject.org/ns2/"/>
      <nsName ns="http://myproject.org/ns3/"/>
      </except>
      </anyName>

      Because it's used in lots of places, I'd like to factor the name-class declaration out into a
      separate file and reference the name class declaration in the locations where it appears in
      my files, so if my namespaces change, I can maintain them in one place.

      The problem is, in RNG a name-class is not a pattern. So to factor it out into an
      <externalRef> does not seem to be possible, since <externalRef/> requires the contents
      of the referenced file to be a valid pattern.

      Nor can I seem to use <include> to insert a reference to this fragment, because a name-
      class can't be the immediate child of a <define> or <grammar> element, for the same
      reason as above.

      So in RNG, is there a clever way to factor out name-class declarations into a separate file
      and reference them as externals in some way?

      Or am I missing the boat entirely here?

      John
    • Dave Pawson
      ... Assuming you have many files, just reference it where wanted, and add it as another pattern in an existing file which matches the constraints you ve found?
      Message 2 of 9 , Dec 9, 2008
      • 0 Attachment
        2008/12/8 john.madden58 <john.madden@...>:
        > I hope somebody can help me. In a big RNG project that contains many files,
        > I repeatedly
        > use a particular name-class in various places throughout the project. (It's
        > the name class
        > of all names that are not in any of the namespaces used by my project, i.e.
        > the foreign
        > name class with respect to my project's namespaces.)
        >
        > <anyName>
        > <except>
        > <nsName ns="http://myproject.org/ns1/"/>
        > <nsName ns="http://myproject.org/ns2/"/>
        > <nsName ns="http://myproject.org/ns3/"/>
        > </except>
        > </anyName>
        >
        > Because it's used in lots of places, I'd like to factor the name-class
        > declaration out into a
        > separate file and reference the name class declaration


        Assuming you have many files,
        just reference it where wanted,
        and add it as another pattern in an existing file
        which matches the constraints you've found?
        Untested.


        HTH




        --
        Dave Pawson
        XSLT XSL-FO FAQ.
        Docbook FAQ.
        http://www.dpawson.co.uk
      • Jirka Kosek
        ... No, unfortunately this is not possible. This is on list of features that could be added to some future version of RELAX NG:
        Message 3 of 9 , Dec 9, 2008
        • 0 Attachment
          john.madden58 wrote:

          > So in RNG, is there a clever way to factor out name-class declarations into a separate file
          > and reference them as externals in some way?

          No, unfortunately this is not possible. This is on list of features that
          could be added to some future version of RELAX NG:

          http://wiki.oasis-open.org/relax-ng/FutureRequirements

          James Clark recently even proposed syntax for this feature:

          http://tech.groups.yahoo.com/group/rng-users/message/914

          But of course this is not yet implemented, but your request justifies
          need for this feature again so might be it is time to push for this
          feature little bit more.

          James, if you are reading this message, do you think that it would be
          possible to implement your proposal in Jing and add new switch which
          will enable this post 1.0 feature?

          I think at the same time it might be useful to create XSLT stylesheet
          (or augment Trang) to convert schemas with this feature to schemas which
          are pure RELAX NG 1.0. This will allow easier authoring of schemas, but
          for deployment schema could be converted to format understood by all
          existing RELAX NG implementations.

          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 member
          ------------------------------------------------------------------
        • James Clark
          There is so much work to do on Jing/Trang just supporting RELAX NG as is that I am reluctant to invest much effort in implementing possible future features
          Message 4 of 9 , Dec 9, 2008
          • 0 Attachment
            There is so much work to do on Jing/Trang just supporting RELAX NG as
            is that I am reluctant to invest much effort in implementing possible
            future features until there is a good level of consensus that a new
            version of RELAX NG is desirable and that proposed features belong in
            it.

            Certainly, if/when that consensus exists, and the standardization
            activity for a new version of RELAX NG has started, then I would
            definitely hope to implement new features in Jing, and to provide a
            Trang option to convert a schema that uses those features into a RELAX
            NG 1.0 schema (to the extent that this is possible).

            James

            On Tue, Dec 9, 2008 at 7:03 PM, Jirka Kosek <jirka@...> wrote:
            > john.madden58 wrote:
            >
            >> So in RNG, is there a clever way to factor out name-class declarations into a separate file
            >> and reference them as externals in some way?
            >
            > No, unfortunately this is not possible. This is on list of features that
            > could be added to some future version of RELAX NG:
            >
            > http://wiki.oasis-open.org/relax-ng/FutureRequirements
            >
            > James Clark recently even proposed syntax for this feature:
            >
            > http://tech.groups.yahoo.com/group/rng-users/message/914
            >
            > But of course this is not yet implemented, but your request justifies
            > need for this feature again so might be it is time to push for this
            > feature little bit more.
            >
            > James, if you are reading this message, do you think that it would be
            > possible to implement your proposal in Jing and add new switch which
            > will enable this post 1.0 feature?
            >
            > I think at the same time it might be useful to create XSLT stylesheet
            > (or augment Trang) to convert schemas with this feature to schemas which
            > are pure RELAX NG 1.0.
          • john.madden58
            I completely understand James concern. Consider this a vote for increasing the priority of this issue/feature in a future RNG 1.1/Jing 1.1. In the meantiime,
            Message 5 of 9 , Dec 9, 2008
            • 0 Attachment
              I completely understand James' concern. Consider this a vote for increasing the priority of
              this issue/feature in a future RNG 1.1/Jing 1.1.

              In the meantiime, does anybody have any clever (even if kludgy) workarounds? Cutesy way
              of using entities, perhaps? I'm struggling here to come up with something.

              John

              --- In rng-users@yahoogroups.com, "James Clark" <jjc@...> wrote:
              >
              > There is so much work to do on Jing/Trang just supporting RELAX NG as
              > is that I am reluctant to invest much effort in implementing possible
              > future features until there is a good level of consensus that a new
              > version of RELAX NG is desirable and that proposed features belong in
              > it.
              >
              > Certainly, if/when that consensus exists, and the standardization
              > activity for a new version of RELAX NG has started, then I would
              > definitely hope to implement new features in Jing, and to provide a
              > Trang option to convert a schema that uses those features into a RELAX
              > NG 1.0 schema (to the extent that this is possible).
              >
              > James
            • Jirka Kosek
              ... If you are using XML syntax of RELAX NG you can use XIncludes. -- ... Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz ... Professional XML
              Message 6 of 9 , Dec 9, 2008
              • 0 Attachment
                john.madden58 wrote:

                > In the meantiime, does anybody have any clever (even if kludgy) workarounds? Cutesy way
                > of using entities, perhaps? I'm struggling here to come up with something.

                If you are using XML syntax of RELAX NG you can use XIncludes.

                --
                ------------------------------------------------------------------
                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 member
                ------------------------------------------------------------------
              • john.madden58
                Jirka, I will give XInclude a try. As a follow-up, I looked at the link you gave to a post of James thinking about possible syntax for making nameClasses be
                Message 7 of 9 , Dec 9, 2008
                • 0 Attachment
                  Jirka,

                  I will give XInclude a try.

                  As a follow-up, I looked at the link you gave to a post of James thinking about possible
                  syntax for making nameClasses be patterns.

                  I have a comment, which is that maybe the idea of making them full-fledged patterns is
                  unnecessarily ambitious. I'm guessing that in 80%+ of use cases, the practical problem
                  could be addressed simply by (1) allowing <externalRef> to wrap a nameClass definition.

                  If in addition you (2) allow nameClasses to have names and (3) allow <parentRef> to refer
                  to a named nameClass in the scope of the parent grammar, then you probably have
                  covered 95%+ of use cases.

                  This solution entails some "punning" on the meaning of <externalRef>, <parentRef> and
                  of the meaning of a "name" attribute -- and if you didn't like that, you could instead
                  create new syntactical elements, something like <externalNameClass> for (1) and
                  <parentNameClassRef> for (2), etc.

                  Point is, I don't think nameClasses necessarily need to treated totally like 100% full-
                  fledged patterns -- just enough to support actual modular design use cases.

                  John
                • Jirka Kosek
                  ... Have you look to mails linked from requirements page at OASIS wiki? They show use cases where there is a need for pattern-like behavior for name classes.
                  Message 8 of 9 , Dec 10, 2008
                  • 0 Attachment
                    john.madden58 wrote:

                    > Point is, I don't think nameClasses necessarily need to treated totally like 100% full-
                    > fledged patterns -- just enough to support actual modular design use cases.

                    Have you look to mails linked from requirements page at OASIS wiki? They
                    show use cases where there is a need for pattern-like behavior for name
                    classes.

                    --
                    ------------------------------------------------------------------
                    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 member
                    ------------------------------------------------------------------
                  • john.madden58
                    Jirka, I ll take a look. John
                    Message 9 of 9 , Dec 10, 2008
                    • 0 Attachment
                      Jirka,

                      I'll take a look.

                      John

                      > Have you look to mails linked from requirements page at OASIS wiki? They
                      > show use cases where there is a need for pattern-like behavior for name
                      > classes.
                      >
                      > --
                      > ------------------------------------------------------------------
                      > 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 member
                      > ------------------------------------------------------------------
                      >
                    Your message has been successfully submitted and would be delivered to recipients shortly.