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

php and nxml

Expand Messages
  • Lennart Borgman
    I have something like this in a php file: Home The nxml parser gets upset when finding
    Message 1 of 29 , Nov 6, 2005
    • 0 Attachment
      I have something like this in a php file:

      <a href="<?php echo get_settings('home'); ?>">Home</a>

      The nxml parser gets upset when finding < inside the doublequotes. I
      think this is correct according to the DTD, but I would like a more php
      friendly dtd. All I really want at the moment is then that < is allowed
      in the href value.

      Is this easy to fix? Has someone tried to do it?
    • J.Pietschmann
      ... PHP scripts are not XML. Repeat: PHP scripts are not XML. At least not in general. The XML spec forbids literal
      Message 2 of 29 , Nov 6, 2005
      • 0 Attachment
        Lennart Borgman wrote:
        > I have something like this in a php file:
        >
        > <a href="<?php echo get_settings('home'); ?>">Home</a>
        >
        > The nxml parser gets upset when finding < inside the doublequotes.

        PHP scripts are not XML. Repeat: PHP scripts are not XML. At least not
        in general. The XML spec forbids literal < and & in attribute values.
        No amount of fiddling with schemas will change this.

        J.Pietschmann
      • Lennart Borgman
        ... Yes, thanks, but does the nxml parser forbid it? It would be very convinient if the parser allowed it. Is it possible in some way to allow it? Or, maybe
        Message 3 of 29 , Nov 6, 2005
        • 0 Attachment
          J.Pietschmann wrote:

          >Lennart Borgman wrote:
          >
          >
          >>I have something like this in a php file:
          >>
          >> <a href="<?php echo get_settings('home'); ?>">Home</a>
          >>
          >>The nxml parser gets upset when finding < inside the doublequotes.
          >>
          >>
          >
          >PHP scripts are not XML. Repeat: PHP scripts are not XML. At least not
          >in general. The XML spec forbids literal < and & in attribute values.
          >No amount of fiddling with schemas will change this.
          >
          >J.Pietschmann
          >
          >
          Yes, thanks, but does the nxml parser forbid it? It would be very
          convinient if the parser allowed it. Is it possible in some way to allow
          it?

          Or, maybe rather: Is is easy to change the nxml-parser to allow < and &
          in attribute values?
        • Lennart Borgman
          ... Here are some further comments if someone is thinking about this: The idea of .php web pages as far as I understand it is that a php page looks like a
          Message 4 of 29 , Nov 6, 2005
          • 0 Attachment
            Lennart Borgman wrote:

            >J.Pietschmann wrote:
            >
            >
            >
            >>Lennart Borgman wrote:
            >>
            >>
            >>
            >>
            >>>I have something like this in a php file:
            >>>
            >>> <a href="<?php echo get_settings('home'); ?>">Home</a>
            >>>
            >>>The nxml parser gets upset when finding < inside the doublequotes.
            >>>
            >>>
            >>>
            >>>
            >>PHP scripts are not XML. Repeat: PHP scripts are not XML. At least not
            >>in general. The XML spec forbids literal < and & in attribute values.
            >>No amount of fiddling with schemas will change this.
            >>
            >>J.Pietschmann
            >>
            >>
            >>
            >>
            >Yes, thanks, but does the nxml parser forbid it? It would be very
            >convinient if the parser allowed it. Is it possible in some way to allow
            >it?
            >
            >Or, maybe rather: Is is easy to change the nxml-parser to allow < and &
            >in attribute values?
            >
            >
            Here are some further comments if someone is thinking about this:


            The idea of
            .php web pages as far as I understand it is that a php page looks like a
            xhtml (or html) page except for some parts having the special <?php ..
            ?> markup. These parts are preprocessed by php before the page is sent
            to the users browser.

            I guess that in a well formed php page <?php ... ?> part corresponds to
            something that perhaps can be called a "syntactic unit" (this name is
            just my invention) in xml. It could be a whole tag or an attribute value
            for example.

            It seems like nxml knows a bit about the <?php ... ?> syntax. If it is
            at "tag level" then at least nxml-forward-element passes that part if it
            is in the inner of an element to move over. Is there something in the
            xml specifications that corresponds to this behaviour?

            However when <?php ... ?> is the attribute value then nxml parser fails
            to handle it (and it should). I suspect that it fails very early in the
            parsing. It looks like there is a regexp pattern in xmltok.el called
            xmltok-attribute that does not allow < in the attribute value. But I am
            not sure of this, since I do not understand how it works. Maybe it is
            possible to change this regexp pattern, but later phases in the parsing
            process might depend on it.

            And then in a later phase (I guess) the attribute value check must be
            skipped.

            This was just some comments if anyone else is also interested in getting
            this working. The reason someone maybe could be is that nxml is good for
            editing xhtml files.
          • Søren Lund
            ... The above way of doing php is a bit old fashioned . I would suggest switching to a template engine, like Smarty (http://smarty.php.net/). Then the line
            Message 5 of 29 , Nov 6, 2005
            • 0 Attachment
              --- In emacs-nxml-mode@yahoogroups.com, Lennart Borgman
              <lennart.borgman.073@s...> wrote:
              >
              > I have something like this in a php file:
              >
              > <a href="<?php echo get_settings('home'); ?>">Home</a>
              >

              The above way of doing php is a bit "old fashioned". I would suggest
              switching to a template engine, like Smarty (http://smarty.php.net/).
              Then the line could be written as:

              <a href="{$settings[home]}">Home</a>

              Not only does it look nicer to humans, it shouldn't upset the nxml
              parser (and you get all the extra features that Smarty delivers).


              - Søren
            • Lennart Borgman
              ... Thanks Søren. I did not know about that. However in this particular case I am not the author, rather the user. The application I am using is WordPress. I
              Message 6 of 29 , Nov 7, 2005
              • 0 Attachment
                Søren Lund wrote:

                >--- In emacs-nxml-mode@yahoogroups.com, Lennart Borgman
                ><lennart.borgman.073@s...> wrote:
                >
                >
                >>I have something like this in a php file:
                >>
                >> <a href="<?php echo get_settings('home'); ?>">Home</a>
                >>
                >>
                >>
                >
                >The above way of doing php is a bit "old fashioned". I would suggest
                >switching to a template engine, like Smarty (http://smarty.php.net/).
                >Then the line could be written as:
                >
                > <a href="{$settings[home]}">Home</a>
                >
                >Not only does it look nicer to humans, it shouldn't upset the nxml
                >parser (and you get all the extra features that Smarty delivers).
                >
                >
                >
                >
                Thanks Søren. I did not know about that. However in this particular case
                I am not the author, rather the user. The application I am using is
                WordPress. I thought I would not roll my own this time ...

                I think it is a more general issue with nxml-mode. I do not believe
                James Clark thought that we should use it for php pages. They are of
                course not xml. But since he wrote such a nice peace of software it is
                tempting to try to use it for a little bit more than he thought of at
                the time he wrote it.

                I looked a bit at the code, but it is not easy. What I am thinking about
                is if there would be any way to tell the scanner to just skip over
                certain parts. If it could skip over <?php ... ?> that would do the
                trick here. That could perhaps be generalized to other situations where
                nxml should not scan the whole file. (Style tags for example.)

                Ideas are wellcome!;-)
              • Dave Pawson
                ... No, it is written for XML, and handles that very well. If you choose to use it for other syntax s then you ll need to accept that there are risks. ... Why,
                Message 7 of 29 , Nov 7, 2005
                • 0 Attachment
                  On 07/11/05, Lennart Borgman <lennart.borgman.073@...> wrote:

                  > I think it is a more general issue with nxml-mode. I do not believe
                  > James Clark thought that we should use it for php pages.

                  No, it is written for XML, and handles that very well.
                  If you choose to use it for other syntax's then you'll need
                  to accept that there are risks.


                  >
                  > I looked a bit at the code, but it is not easy. What I am thinking about
                  > is if there would be any way to tell the scanner to just skip over
                  > certain parts. If it could skip over <?php ... ?>

                  Why, when that would screw the handling of XML?
                  http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-pi

                  regards


                  -
                  Dave Pawson
                  XSLT XSL-FO FAQ.
                  http://www.dpawson.co.uk
                • Lennart Borgman
                  ... Yes, I know and I agree. It is just that it would be nice in my opinion to have a little bit tweaked nxml-mode working for php as well. But php pages are
                  Message 8 of 29 , Nov 7, 2005
                  • 0 Attachment
                    Dave Pawson wrote:

                    >No, it is written for XML, and handles that very well.
                    >If you choose to use it for other syntax's then you'll need
                    >to accept that there are risks.
                    >
                    >
                    Yes, I know and I agree. It is just that it would be nice in my opinion
                    to have a little bit tweaked nxml-mode working for php as well. But php
                    pages are not always xml. Please excuse me and correct me however if I
                    say stupidities, I am not at all an xml expert!

                    >
                    >
                    >
                    >>I looked a bit at the code, but it is not easy. What I am thinking about
                    >>is if there would be any way to tell the scanner to just skip over
                    >>certain parts. If it could skip over <?php ... ?>
                    >>
                    >>
                    >
                    >Why, when that would screw the handling of XML?
                    >http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-pi
                    >
                    >
                    Thanks. Can you please explain this a bit to me? Does that mean that
                    <?php ... ?> could be part of an xml document when it is on "tag level"?
                    I was not aware of that.

                    My current problem is that <?php ... ?> is used as attribute value,
                    something like this:

                    <a href="<?php home_page(); ?>">Home</a>

                    That is not allowed in xml I have learned now. All I want now is
                    nxml-mode to forgive this bad syntax and pretend it is good (using some
                    switch). Maybe it is a bad idea, but I can not find any better at the
                    moment?
                  • Dave Pawson
                    ... Which makes the two things incompatible? XML and *some* php files? ... Yes, if you look at the url, it is a Processing instruction; Meant to be application
                    Message 9 of 29 , Nov 7, 2005
                    • 0 Attachment
                      On 07/11/05, Lennart Borgman <lennart.borgman.073@...> wrote:

                      > Yes, I know and I agree. It is just that it would be nice in my opinion
                      > to have a little bit tweaked nxml-mode working for php as well. But php
                      > pages are not always xml.

                      Which makes the two things incompatible?
                      XML and *some* php files?



                      > >>I looked a bit at the code, but it is not easy. What I am thinking about
                      > >>is if there would be any way to tell the scanner to just skip over
                      > >>certain parts. If it could skip over <?php ... ?>
                      > >>
                      > >>
                      > >
                      > >Why, when that would screw the handling of XML?
                      > >http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-pi
                      > >
                      > >
                      > Thanks. Can you please explain this a bit to me? Does that mean that
                      > <?php ... ?> could be part of an xml document when it is on "tag level"?
                      > I was not aware of that.

                      Yes, if you look at the url, it is a Processing instruction;
                      Meant to be application specific,
                      e.g.
                      <?mynewPage ?> might be used to output a new page in a page oriented
                      application.




                      >
                      > My current problem is that <?php ... ?> is used as attribute value,
                      > something like this:
                      >
                      > <a href="<?php home_page(); ?>">Home</a>
                      >
                      > That is not allowed in xml I have learned now. All I want now is
                      > nxml-mode to forgive this bad syntax and pretend it is good (using some
                      > switch). Maybe it is a bad idea, but I can not find any better at the
                      > moment?

                      http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-AttValue

                      AttValue ::= '"' ([^<&"] | Reference)* '"'
                      | "'" ([^<&'] | Reference)* "'"

                      So it looks like an XML attribute cannot contain the '<' character?


                      Perhaps a PHP mode for emacs, if there is one?
                      http://sourceforge.net/projects/php-mode/ etc.

                      If you want nxml-mode to do something it is not meant to do,
                      then you will have to modify it?

                      regards



                      --
                      Dave Pawson
                      XSLT XSL-FO FAQ.
                      http://www.dpawson.co.uk
                    • Vincent Lefevre
                      ... It is not a nxml-mode issue, but a PHP issue. ... There exists a php-mode. Why don t you use it? If you don t like some features in it either, then this is
                      Message 10 of 29 , Nov 7, 2005
                      • 0 Attachment
                        On 2005-11-07 14:32:53 +0100, Lennart Borgman wrote:
                        > I think it is a more general issue with nxml-mode.

                        It is not a nxml-mode issue, but a PHP issue.

                        > I do not believe James Clark thought that we should use it for php
                        > pages. They are of course not xml. But since he wrote such a nice
                        > peace of software it is tempting to try to use it for a little bit
                        > more than he thought of at the time he wrote it.

                        There exists a php-mode. Why don't you use it? If you don't like
                        some features in it either, then this is this mode that should be
                        modified, not nxml-mode, that works very well with XML.

                        --
                        Vincent Lefèvre <vincent@...> - Web: <http://www.vinc17.org/>
                        100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
                        Work: CR INRIA - computer arithmetic / SPACES project at LORIA
                      • Lennart Borgman
                        ... Yes. ... Thanks, I see. Then it looks like php was written to be xml compliant, but that it fails in the case below. ... Thanks. ... nxml-mode is better
                        Message 11 of 29 , Nov 7, 2005
                        • 0 Attachment
                          Dave Pawson wrote:

                          >Which makes the two things incompatible?
                          >XML and *some* php files?
                          >
                          >
                          Yes.

                          >Yes, if you look at the url, it is a Processing instruction;
                          >Meant to be application specific,
                          >e.g.
                          ><?mynewPage ?> might be used to output a new page in a page oriented
                          >application.
                          >
                          >
                          Thanks, I see. Then it looks like php was written to be xml compliant,
                          but that it fails in the case below.

                          >>My current problem is that <?php ... ?> is used as attribute value,
                          >>something like this:
                          >>
                          >> <a href="<?php home_page(); ?>">Home</a>
                          >>
                          >>That is not allowed in xml I have learned now. All I want now is
                          >>nxml-mode to forgive this bad syntax and pretend it is good (using some
                          >>switch). Maybe it is a bad idea, but I can not find any better at the
                          >>moment?
                          >>
                          >>
                          >
                          >http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-AttValue
                          >
                          > AttValue ::= '"' ([^<&"] | Reference)* '"'
                          > | "'" ([^<&'] | Reference)* "'"
                          >
                          >So it looks like an XML attribute cannot contain the '<' character?
                          >
                          >
                          Thanks.

                          >
                          >Perhaps a PHP mode for emacs, if there is one?
                          >http://sourceforge.net/projects/php-mode/ etc.
                          >
                          >
                          nxml-mode is better for my purposes I believe ;-)

                          >If you want nxml-mode to do something it is not meant to do,
                          >then you will have to modify it?
                          >
                          >
                          Yes, I am trying to understand how to do this little modification.
                          Asking here is a way of clearing my thoughts and also getting to know if
                          someone else has tried this.
                        • Vincent Lefevre
                          ... I think the only way would be a configuration variable that makes
                          Message 12 of 29 , Nov 7, 2005
                          • 0 Attachment
                            On 2005-11-07 16:14:44 +0100, Lennart Borgman wrote:
                            > My current problem is that <?php ... ?> is used as attribute value,
                            > something like this:
                            >
                            > <a href="<?php home_page(); ?>">Home</a>
                            >
                            > That is not allowed in xml I have learned now. All I want now is
                            > nxml-mode to forgive this bad syntax and pretend it is good (using some
                            > switch). Maybe it is a bad idea, but I can not find any better at the
                            > moment?

                            I think the only way would be a configuration variable that makes
                            "<" allowed in an attribute; normal users would let it set to nil,
                            and PHP users could set it to allow things like:

                            <a href="<?php home_page(); ?>">Home</a>

                            I haven't looked at the code (a nxml-mode developer could tell you),
                            and I'm not sure that this is possible since nxml-mode should allow
                            to cope with "errors" in a nice way for the user. I mean, when you
                            are editing a document, errors must occur just because you haven't
                            finished editing it.

                            For instance, consider

                            <elem attr="><child>"></child></elem>
                            ^cursor

                            that can happen when you're adding an attribute. If "<" is allowed
                            in an attribute value, then the error information given by nxml-mode
                            would have to be very different. So, assuming that "<" can sometimes
                            be allowed could make the code (current or future) not adapted for
                            normal XML users. In short, this is not acceptable.

                            If this just needs a few lines change, why not... But I wonder if
                            this would solve any problem. If " is allowed inside <?php ... ?>,
                            then I don't think there would be a simple change in nxml-mode.

                            --
                            Vincent Lefèvre <vincent@...> - Web: <http://www.vinc17.org/>
                            100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
                            Work: CR INRIA - computer arithmetic / SPACES project at LORIA
                          • Lennart Borgman
                            ... Yes, that is the way I am thinking. ... That is difficult to handle, but at the moment I want to skip that. An argument would just be anything between
                            Message 13 of 29 , Nov 7, 2005
                            • 0 Attachment
                              Vincent Lefevre wrote:

                              >I think the only way would be a configuration variable that makes
                              >"<" allowed in an attribute; normal users would let it set to nil,
                              >and PHP users could set it to allow things like:
                              >
                              > <a href="<?php home_page(); ?>">Home</a>
                              >
                              >
                              Yes, that is the way I am thinking.

                              >I haven't looked at the code (a nxml-mode developer could tell you),
                              >and I'm not sure that this is possible since nxml-mode should allow
                              >to cope with "errors" in a nice way for the user. I mean, when you
                              >are editing a document, errors must occur just because you haven't
                              >finished editing it.
                              >
                              >For instance, consider
                              >
                              > <elem attr="><child>"></child></elem>
                              > ^cursor
                              >
                              >
                              That is difficult to handle, but at the moment I want to skip that. An
                              argument would just be anything between "..." (or '...') with the flag
                              above turned on. For my purpose that would be quite good.

                              However a better solution would probably be to deal with just that <?php
                              ... ?> inside the attribute value. If there is any such thing then turn
                              on the flag above for that attribute, otherwise not. (No I am mixing
                              different meanings of "flag" - global or local - but I think this is
                              possible to understand?)

                              >If this just needs a few lines change, why not... But I wonder if
                              >this would solve any problem. If " is allowed inside <?php ... ?>,
                              >then I don't think there would be a simple change in nxml-mode.
                              >
                              >
                              Maybe that could be handled with a little extension to what I suggested
                              as the "bigger" solution above.

                              Now I will take some rest and think about it. Thanks everyone for the
                              comments! More comments are still wellcome!
                            • Justus Piater
                              I use emacs mmm-mode (http://mmm-mode.sourceforge.net/) for exactly this purpose. It allows to assign different major modes to different sections within the
                              Message 14 of 29 , Nov 9, 2005
                              • 0 Attachment
                                I use emacs' mmm-mode (http://mmm-mode.sourceforge.net/) for exactly
                                this purpose. It allows to assign different major modes to different
                                sections within the same buffer. I have set it up to handle .php files
                                under nxml-mode, but <?php...?> sections within them are handled by
                                php-mode. Works well for me (after some tweaking for my particular
                                setup; ask for details if you run into problems.)

                                Justus

                                --
                                Justus H. Piater, Ph.D. http://www.montefiore.ulg.ac.be/~piater/
                                Institut Montefiore, B28 Phone: +32-4-366-2279
                                Université de Liège, Belgium Fax: +32-4-366-2620
                              • Lennart Borgman
                                ... Thanks Justus, that sounds nice. There is actually an entry on http://www.emacswiki.org/cgi-bin/wiki/NxmlModeForXHTML where Dean Scarff says he has got
                                Message 15 of 29 , Nov 9, 2005
                                • 0 Attachment
                                  Justus Piater wrote:

                                  >I use emacs' mmm-mode (http://mmm-mode.sourceforge.net/) for exactly
                                  >this purpose. It allows to assign different major modes to different
                                  >sections within the same buffer. I have set it up to handle .php files
                                  >under nxml-mode, but <?php...?> sections within them are handled by
                                  >php-mode. Works well for me (after some tweaking for my particular
                                  >setup; ask for details if you run into problems.)
                                  >
                                  >
                                  Thanks Justus, that sounds nice. There is actually an entry on
                                  http://www.emacswiki.org/cgi-bin/wiki/NxmlModeForXHTML where Dean Scarff
                                  says he has got mmm-mode nearly working with nxml-mode. Maybe you could
                                  have a look at that and clarify how you got it working? You could send
                                  me the info and I can edit the wiki page or you can edit the wiki page
                                  yourself.

                                  Does indentation also work with mmm-mode?
                                • Justus Piater
                                  Lennart Borgman wrote on Wed, 09 ... I think it worked out-of-the-box. All I did specially has to do with my personal
                                  Message 16 of 29 , Nov 11, 2005
                                  • 0 Attachment
                                    Lennart Borgman <lennart.borgman.073@...> wrote on Wed, 09
                                    Nov 2005 23:02:37 +0100:

                                    > Justus Piater wrote:
                                    >>I use emacs' mmm-mode (http://mmm-mode.sourceforge.net/)
                                    >>
                                    > There is actually an entry on
                                    > http://www.emacswiki.org/cgi-bin/wiki/NxmlModeForXHTML where Dean
                                    > Scarff says he has got mmm-mode nearly working with nxml-mode. Maybe
                                    > you could have a look at that and clarify how you got it working?

                                    I think it worked out-of-the-box. All I did specially has to do with
                                    my personal setup:

                                    - Most of my PHP pages require() a header and a footer, so they are
                                    not valid XHTML documents. I worked around this by defining a
                                    trivial customization of the XHTML rnc grammar that is happy with a
                                    <div> root element. This requires that each .php source's content be
                                    enclosed in a <div>, but this does not impose any limitations.

                                    - My pages use ISO-8859-1 encoding, whereas nxml-mode insists on utf-8
                                    unless otherwise specified in the xml declaration. However, with my
                                    setup an xml declaration would yield invalid XHTML, so I cannot use
                                    it. My (ugly) workaround is to set write-contents-hooks to nil in
                                    the Local variables: section, which requires user confirmation when
                                    the file is loaded into Emacs. It would be nice if nxml-mode
                                    included a customizable local variable for the default encoding, but
                                    James Clark seems too busy.

                                    The fontification problems associated with mmm-mode are real, but I
                                    don't find them too disturbing. When you edit a PHP section, sooner or
                                    later the fontification will catch up.

                                    IIRC, the upcoming Emacs release will provide native support for
                                    multiple major modes within a single buffer.

                                    > Does indentation also work with mmm-mode?

                                    Yes, no problem.

                                    Justus

                                    --
                                    Justus H. Piater, Ph.D. http://www.montefiore.ulg.ac.be/~piater/
                                    Institut Montefiore, B28 Phone: +32-4-366-2279
                                    Université de Liège, Belgium Fax: +32-4-366-2620
                                  • Lennart Borgman
                                    ... From your comments it looks more like out-of-the-head ;-) ... I would be glad if you wanted to share this trivial customization with us. That would
                                    Message 17 of 29 , Nov 11, 2005
                                    • 0 Attachment
                                      Justus Piater wrote:

                                      >I think it worked out-of-the-box.
                                      >
                                      From your comments it looks more like out-of-the-head ;-)

                                      >- Most of my PHP pages require() a header and a footer, so they are
                                      > not valid XHTML documents. I worked around this by defining a
                                      > trivial customization of the XHTML rnc grammar that is happy with a
                                      > <div> root element.
                                      >
                                      >
                                      I would be glad if you wanted to share this "trivial" customization with
                                      us. That would perhaps be good for a start.

                                      >- My pages use ISO-8859-1 encoding, whereas nxml-mode insists on utf-8
                                      > unless otherwise specified in the xml declaration. However, with my
                                      > setup an xml declaration would yield invalid XHTML, so I cannot use
                                      > it. My (ugly) workaround is to set write-contents-hooks to nil in
                                      > the Local variables: section, which requires user confirmation when
                                      > the file is loaded into Emacs. It would be nice if nxml-mode
                                      > included a customizable local variable for the default encoding, but
                                      > James Clark seems too busy.
                                      >
                                      >
                                      Hm. Could be part of another problem I have seen where I have trouble
                                      enter an a with ring. Would not that be a trivial change? ;-)

                                      >The fontification problems associated with mmm-mode are real, but I
                                      >don't find them too disturbing. When you edit a PHP section, sooner or
                                      >later the fontification will catch up.
                                      >
                                      >
                                      Thanks for the info. But does not nxml-mode still insists on fontifying
                                      the php sections?

                                      >IIRC, the upcoming Emacs release will provide native support for
                                      >multiple major modes within a single buffer.
                                      >
                                      >
                                      Is it? Can you tell me what you think of? This is nothing that I am
                                      aware of, but it would be very good.

                                      >
                                      >
                                      >>Does indentation also work with mmm-mode?
                                      >>
                                      >>
                                      >
                                      >Yes, no problem.
                                      >
                                      >
                                      Thanks, then maybe I should learn more about how indentation works in
                                      php-mode. Which php-mode where you using? (BTW it would be good if they
                                      had different names.)
                                    • Jason Rumney
                                      ... It might be trivial, but it would also be wrong. Part of the xml spec is that the encoding is utf-8 unless otherwise specified in the xml header. The
                                      Message 18 of 29 , Nov 11, 2005
                                      • 0 Attachment
                                        Lennart Borgman wrote:

                                        >Justus Piater wrote:
                                        >
                                        >
                                        >> It would be nice if nxml-mode
                                        >> included a customizable local variable for the default encoding, but
                                        >> James Clark seems too busy.
                                        >>
                                        >>
                                        >Hm. Could be part of another problem I have seen where I have trouble
                                        >enter an a with ring. Would not that be a trivial change? ;-)
                                        >
                                        >
                                        It might be trivial, but it would also be wrong. Part of the xml spec is
                                        that the encoding is utf-8 unless otherwise specified in the xml header.
                                        The strength of nxml-mode compared to psgml-mode and others is that it
                                        limits itself to XML, and does that well. All these hacks to make
                                        nxml-mode work better with not-quite-xml documents would be better done
                                        with psgml-mode or another SGML mode, that is designed to handle these
                                        sorts of cases.
                                      • Lennart Borgman
                                        ... Thanks, then the current behaviour is surely correct from that point of view. However in my case I will have to think about a workaround since php was not
                                        Message 19 of 29 , Nov 11, 2005
                                        • 0 Attachment
                                          Jason Rumney wrote:

                                          >It might be trivial, but it would also be wrong. Part of the xml spec is
                                          >that the encoding is utf-8 unless otherwise specified in the xml header.
                                          >The strength of nxml-mode compared to psgml-mode and others is that it
                                          >limits itself to XML, and does that well. All these hacks to make
                                          >nxml-mode work better with not-quite-xml documents would be better done
                                          >with psgml-mode or another SGML mode, that is designed to handle these
                                          >sorts of cases.
                                          >
                                          >
                                          Thanks, then the current behaviour is surely correct from that point of
                                          view. However in my case I will have to think about a workaround since
                                          php was not fond of the xhtml spec.

                                          Perhaps psgml-mode would be better to use for files that are not all
                                          xml, like php files. But nxml-mode is very nice because it knows the DTD
                                          and can help with syntax. It is also very nice because it tries to
                                          "resync" with the DTD if there is an error in the file. Am I missing
                                          something about psgml-mode?

                                          I still have the feeling that it could be good to have a way for
                                          nxml-mode to not care about certain parts of the file. Even if that is
                                          not correct xml syntax it could be very useful for editing php files for
                                          example. I guess no one would think it is correct xml syntax so it does
                                          not disturb the user. Maybe it destroys the nxml code and that would be
                                          very bad. To me it seems however that the possiblity to tell nxml-mode
                                          to neglect region is nearly there since rng can "resync".

                                          A problem is I do not understand this things very well and the nxml code
                                          is difficult, at least for me. For someone who understands the code well
                                          it could be a very small and rather trivial change.
                                        • Dave Pawson
                                          ... But it does disturb the validity to the XML standard, as used by nxml-mode? ... Yes, I agree. nxml-mode is very good for XML. Let s keep it that way.
                                          Message 20 of 29 , Nov 11, 2005
                                          • 0 Attachment
                                            On 11/11/05, Lennart Borgman <lennart.borgman.073@...> wrote:



                                            > Perhaps psgml-mode would be better to use for files that are not all
                                            > xml, like php files.

                                            > I guess no one would think it is correct xml syntax so it does
                                            > not disturb the user.
                                            But it does 'disturb' the validity to the XML standard, as used by nxml-mode?

                                            > Maybe it destroys the nxml code and that would be
                                            > very bad.

                                            Yes, I agree. nxml-mode is very good for XML.
                                            Let's keep it that way.



                                            Dave Pawson
                                            XSLT XSL-FO FAQ.
                                            http://www.dpawson.co.uk
                                          • Lennart Borgman
                                            ... Why? Nxml could just as now say that the buffer is not valid XML syntax.
                                            Message 21 of 29 , Nov 11, 2005
                                            • 0 Attachment
                                              Dave Pawson wrote:

                                              >
                                              >But it does 'disturb' the validity to the XML standard, as used by nxml-mode?
                                              >
                                              >
                                              Why? Nxml could just as now say that the buffer is not valid XML syntax.
                                            • Justus Piater
                                              Lennart Borgman wrote on Fri, 11 ... # div blocks containing a subset of XHTML Strict, without namespace include
                                              Message 22 of 29 , Nov 14, 2005
                                              • 0 Attachment
                                                Lennart Borgman <lennart.borgman.073@...> wrote on Fri, 11
                                                Nov 2005 14:28:48 +0100:

                                                > I would be glad if you wanted to share this "trivial" customization with
                                                > us. That would perhaps be good for a start.

                                                Here's what I use:

                                                -------------------------------------------------------------------------
                                                # div blocks containing a subset of XHTML Strict, without namespace

                                                include "datatypes.rnc"
                                                include "attribs.rnc"

                                                include "struct.rnc" {
                                                start = \div
                                                }

                                                include "text.rnc"
                                                include "hypertext.rnc"
                                                include "list.rnc"
                                                include "image.rnc"
                                                include "base.rnc"
                                                include "link.rnc"
                                                include "meta.rnc"
                                                include "param.rnc"
                                                include "object.rnc"
                                                include "pres.rnc"
                                                include "edit.rnc"
                                                include "form.rnc"
                                                include "style.rnc"
                                                include "script.rnc"
                                                include "table.rnc"
                                                include "events.rnc"
                                                include "inlstyle.rnc"
                                                include "nameident.rnc"
                                                -------------------------------------------------------------------------

                                                I don't remember why I stripped the namespace, probably because the
                                                namespace declaration is generated by included PHP code and is not
                                                visible within my .php files.

                                                > Hm. Could be part of another problem I have seen where I have trouble
                                                > enter an a with ring. Would not that be a trivial change? ;-)

                                                C-c C-u "latin small letter a with ring above" works perfectly for me.

                                                > Thanks for the info. But does not nxml-mode still insists on fontifying
                                                > the php sections?

                                                Yes, intermittently, but I can live with that.

                                                >>IIRC, the upcoming Emacs release will provide native support for
                                                >>multiple major modes within a single buffer.
                                                >>
                                                > Is it? Can you tell me what you think of? This is nothing that I am
                                                > aware of, but it would be very good.

                                                From the Emacs TODO:

                                                ** Implement a clean way to use different major modes for
                                                different parts of a buffer.

                                                So, it's on the wish list, but who knows when it will become
                                                reality. It is not mentioned in the NEWS (yet). That's all I know.

                                                > Which php-mode where you using?

                                                ;;; php-mode.el --- major mode for editing PHP code

                                                ;; Copyright (C) 1999-2004 Turadg Aleahmad

                                                ;; Maintainer: Turadg Aleahmad <turadg at users.sourceforge.net>
                                                ;; Keywords: php languages oop
                                                ;; Created: 1999-05-17
                                                ;; Modified: 2004-01-24
                                                ;; X-URL: http://php-mode.sourceforge.net/

                                                (defconst php-version "1.1.0"
                                                "PHP Mode version number.")


                                                Jason Rumney <jasonr@...> wrote on Fri, 11 Nov 2005 13:38:25
                                                +0000:

                                                >>Justus Piater wrote:
                                                >>
                                                >>> It would be nice if nxml-mode included a customizable local
                                                >>> variable for the default encoding
                                                >>
                                                > It might be trivial, but it would also be wrong. Part of the xml spec is
                                                > that the encoding is utf-8 unless otherwise specified in the xml header.

                                                You are absolutely right. I abuse nxml-mode to help me edit text that
                                                is not XML but very close to it.

                                                Justus

                                                --
                                                Justus H. Piater, Ph.D. http://www.montefiore.ulg.ac.be/~piater/
                                                Institut Montefiore, B28 Phone: +32-4-366-2279
                                                Université de Liège, Belgium Fax: +32-4-366-2620
                                              • Vincent Lefevre
                                                ... nxml-mode doesn t use the DTD (or possibly only for entities?), but a RNC schema. ... Only if this wouldn t bloat it; nxml-mode must still be very fast in
                                                Message 23 of 29 , Nov 14, 2005
                                                • 0 Attachment
                                                  On 2005-11-11 15:00:43 +0100, Lennart Borgman wrote:
                                                  > Perhaps psgml-mode would be better to use for files that are not all
                                                  > xml, like php files. But nxml-mode is very nice because it knows the DTD
                                                  > and can help with syntax. It is also very nice because it tries to

                                                  nxml-mode doesn't use the DTD (or possibly only for entities?), but
                                                  a RNC schema.

                                                  > I still have the feeling that it could be good to have a way for
                                                  > nxml-mode to not care about certain parts of the file.

                                                  Only if this wouldn't bloat it; nxml-mode must still be very fast
                                                  in the "normal" cases.

                                                  --
                                                  Vincent Lefèvre <vincent@...> - Web: <http://www.vinc17.org/>
                                                  100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
                                                  Work: CR INRIA - computer arithmetic / SPACES project at LORIA
                                                • Vincent Lefevre
                                                  ... nxml-mode does more than that. It also says where the errors are and does this very nicely, with a minimal set of errors. For instance, the fact that the
                                                  Message 24 of 29 , Nov 14, 2005
                                                  • 0 Attachment
                                                    On 2005-11-11 15:20:01 +0100, Lennart Borgman wrote:
                                                    > Dave Pawson wrote:
                                                    > >But it does 'disturb' the validity to the XML standard, as used by
                                                    > >nxml-mode?
                                                    > >
                                                    > Why? Nxml could just as now say that the buffer is not valid XML syntax.

                                                    nxml-mode does more than that. It also says where the errors are and
                                                    does this very nicely, with a minimal set of errors. For instance, the
                                                    fact that the character < cannot appear in an attribute value is used
                                                    by nxml-mode in this way. Allowing the user to say that some parts
                                                    should be ignored would probably make things much more complicated to
                                                    do validation on the fly.

                                                    --
                                                    Vincent Lefèvre <vincent@...> - Web: <http://www.vinc17.org/>
                                                    100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
                                                    Work: CR INRIA - computer arithmetic / SPACES project at LORIA
                                                  • Vincent Lefevre
                                                    ... No, this is not completely true. The encoding may be specified in an external way. A customizable local variable could be such an external declaration; so,
                                                    Message 25 of 29 , Nov 14, 2005
                                                    • 0 Attachment
                                                      On 2005-11-14 11:25:24 +0100, Justus Piater wrote:
                                                      > Jason Rumney <jasonr@...> wrote on Fri, 11 Nov 2005 13:38:25
                                                      > +0000:
                                                      >
                                                      > >>Justus Piater wrote:
                                                      > >>
                                                      > >>> It would be nice if nxml-mode included a customizable local
                                                      > >>> variable for the default encoding
                                                      > >>
                                                      > > It might be trivial, but it would also be wrong. Part of the xml
                                                      > > spec is that the encoding is utf-8 unless otherwise specified in
                                                      > > the xml header.
                                                      >
                                                      > You are absolutely right. I abuse nxml-mode to help me edit text
                                                      > that is not XML but very close to it.

                                                      No, this is not completely true. The encoding may be specified in an
                                                      external way. A customizable local variable could be such an external
                                                      declaration; so, such a feature would be acceptable and not contrary
                                                      to the XML specification, which says:

                                                      4.3.3 Character Encoding in Entities
                                                      [...]
                                                      Although an XML processor is required to read only entities in the
                                                      UTF-8 and UTF-16 encodings, it is recognized that other encodings
                                                      are used around the world, and it may be desired for XML processors
                                                      to read entities that use them. In the absence of external character
                                                      encoding information (such as MIME headers), parsed entities which
                                                      are stored in an encoding other than UTF-8 or UTF-16 MUST begin with
                                                      a text declaration (see 4.3.1 The Text Declaration) containing an
                                                      encoding declaration:
                                                      [...]

                                                      --
                                                      Vincent Lefèvre <vincent@...> - Web: <http://www.vinc17.org/>
                                                      100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
                                                      Work: CR INRIA - computer arithmetic / SPACES project at LORIA
                                                    • Lennart Borgman
                                                      ... I guess the result would be no better and no worse than if the sections to ignore where just erased instead. At least that is the simple case I am after
                                                      Message 26 of 29 , Nov 14, 2005
                                                      • 0 Attachment
                                                        Vincent Lefevre wrote:

                                                        >nxml-mode does more than that. It also says where the errors are and
                                                        >does this very nicely, with a minimal set of errors. For instance, the
                                                        >fact that the character < cannot appear in an attribute value is used
                                                        >by nxml-mode in this way. Allowing the user to say that some parts
                                                        >should be ignored would probably make things much more complicated to
                                                        >do validation on the fly.
                                                        >
                                                        >
                                                        I guess the result would be no better and no worse than if the sections
                                                        to ignore where just erased instead.

                                                        At least that is the simple case I am after now. It could perhaps be
                                                        made better. You could say that what will be inserted will make the
                                                        final document valid XML. Probably that would require quite a lot more
                                                        effort.
                                                      • Lennart Borgman
                                                        ... Thanks for the education. I save this. ... I had no idea this was there. Thanks. ... On the page http://www.emacswiki.org/cgi-bin/wiki/PhpMode it says that
                                                        Message 27 of 29 , Nov 14, 2005
                                                        • 0 Attachment
                                                          Justus Piater wrote:

                                                          >Here's what I use:
                                                          >
                                                          >
                                                          Thanks for the education. I save this.

                                                          >C-c C-u "latin small letter a with ring above" works perfectly for me.
                                                          >
                                                          >
                                                          I had no idea this was there. Thanks.

                                                          >>Which php-mode where you using?
                                                          >>
                                                          >>
                                                          >
                                                          >;;; php-mode.el --- major mode for editing PHP code
                                                          >
                                                          >;; Copyright (C) 1999-2004 Turadg Aleahmad
                                                          >
                                                          >;; Maintainer: Turadg Aleahmad <turadg at users.sourceforge.net>
                                                          >;; Keywords: php languages oop
                                                          >;; Created: 1999-05-17
                                                          >;; Modified: 2004-01-24
                                                          >;; X-URL: http://php-mode.sourceforge.net/
                                                          >
                                                          >(defconst php-version "1.1.0"
                                                          > "PHP Mode version number.")
                                                          >
                                                          >
                                                          On the page http://www.emacswiki.org/cgi-bin/wiki/PhpMode it says that
                                                          this modes misbehaves sometimes. What do you think about that?

                                                          (I am using the other php mode because of the statement on that page.)
                                                        • Justus Piater
                                                          Lennart Borgman wrote on Mon, 14 ... I have never noticed any of the mentioned problems. The reporter EtFb on that page
                                                          Message 28 of 29 , Nov 14, 2005
                                                          • 0 Attachment
                                                            Lennart Borgman <lennart.borgman.073@...> wrote on Mon, 14
                                                            Nov 2005 16:06:10 +0100:

                                                            > On the page http://www.emacswiki.org/cgi-bin/wiki/PhpMode it says that
                                                            > this modes misbehaves sometimes. What do you think about that?

                                                            I have never noticed any of the mentioned problems.

                                                            The reporter EtFb on that page cites bug reports but has never used
                                                            the software himself. This is quite a shaky floor for making
                                                            statements about a software.

                                                            The other uses an ancient version of Emacs and an obscure operating
                                                            system that I've never heard of.

                                                            Justus

                                                            --
                                                            Justus H. Piater, Ph.D. http://www.montefiore.ulg.ac.be/~piater/
                                                            Institut Montefiore, B28 Phone: +32-4-366-2279
                                                            Université de Liège, Belgium Fax: +32-4-366-2620
                                                          • Steinar Bang
                                                            ... psgml on the other hand, does use DTDs... if you tell it where to find them.
                                                            Message 29 of 29 , Dec 16, 2005
                                                            • 0 Attachment
                                                              >>>>> Vincent Lefevre <vincent@...>:

                                                              > On 2005-11-11 15:00:43 +0100, Lennart Borgman wrote:

                                                              >> Perhaps psgml-mode would be better to use for files that are not
                                                              >> all xml, like php files. But nxml-mode is very nice because it
                                                              >> knows the DTD and can help with syntax. It is also very nice
                                                              >> because it tries to

                                                              > nxml-mode doesn't use the DTD (or possibly only for entities?), but
                                                              > a RNC schema.

                                                              psgml on the other hand, does use DTDs... if you tell it where to find
                                                              them.
                                                            Your message has been successfully submitted and would be delivered to recipients shortly.