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

XHTML format and nxml-mode

Expand Messages
  • Lennart Borgman
    Is this valid XHTML? (inside the head-tag): function lt(a, b) { return (a nxml-mode complains about the
    Message 1 of 25 , Feb 6, 2006
    • 0 Attachment
      Is this valid XHTML? (inside the head-tag):

      <script type="text/javascript">
      function lt(a, b) {
      return (a < b);
      }
      </script>

      nxml-mode complains about the "<" inside the javascript function. The
      error is

      `<' that is not markup must be entered as `<'

      What should be done with this?

      ----
      Several php files I have seen use constructs like

      <a href="<?php the_link() ?>">

      nxml-mode complains at "<a" with "Missing >" which seems correct to me
      but is inconvenient. Is there some simple way to allow < (or <?) inside
      attribute values?

      Note that I am not thinking about modifying nxml-mode (since several
      people have told me this is a very bad idea), but rather a derived mode
      nxhtml-mode that I use.
    • Victor Anyakin
      ... I think, that nxml-mode is right. XML parser will treat
      Message 2 of 25 , Feb 6, 2006
      • 0 Attachment
        On Tue, Feb 07, 2006 at 12:49:16AM +0100, Lennart Borgman wrote:
        > Is this valid XHTML? (inside the head-tag):
        >
        > <script type="text/javascript">
        > function lt(a, b) {
        > return (a < b);
        > }
        > </script>
        >
        > nxml-mode complains about the "<" inside the javascript function. The
        > error is
        >
        > `<' that is not markup must be entered as `<'
        >
        > What should be done with this?

        I think, that nxml-mode is right. XML parser will treat "<" as a
        start-of-the-tag marker not as a less-than operator of the
        javascript.

        As a workaround you could try to wrap javascript code into the
        <!CDATA[ .... ]> block.

        With best regards,
        --
        Victor Anyakin () ascii ribbon campaign
        /\ - against html mail
      • Vincent Lefevre
        ... This is not valid, and even not well-formed XML. IIRC, this was OK for HTML (as a SGML application) since DTDs are mandatory with SGML. And in particular,
        Message 3 of 25 , Feb 7, 2006
        • 0 Attachment
          On 2006-02-07 00:49:16 +0100, Lennart Borgman wrote:
          > Is this valid XHTML? (inside the head-tag):
          >
          > <script type="text/javascript">
          > function lt(a, b) {
          > return (a < b);
          > }
          > </script>

          This is not valid, and even not well-formed XML. IIRC, this was OK
          for HTML (as a SGML application) since DTDs are mandatory with SGML.
          And in particular, the DTD could say that some element have CDATA
          contents. But any XML document must be parsable without the need
          of a DTD. So, accepting "<" in the contents of some element would
          be ambiguous.

          --
          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
        • John Gage
          In order for outline mode to work in nxml, I believe, out of ignorance, that one must edit the default regex:
          Message 4 of 25 , Feb 7, 2006
          • 0 Attachment
            In order for outline mode to work in nxml, I believe, out of
            ignorance, that one must edit the default regex:

            article\|\(sub\)*section\|chapter\|div\|appendix\|part\|preface\|
            reference\|simplesect\|bibliography\|bibliodiv\|glossary\|glossdiv

            to correspond to one's own tags <foo> <bar> etc.

            I have done this, and I continue to get a "Not in section" error
            whenever I try to use an outline command.

            What am I missing?

            John Gage
          • Florent Georges
            ... Ill-formed. ... What nXML is saying to you: replace
            Message 5 of 25 , Feb 7, 2006
            • 0 Attachment
              Lennart Borgman wrote:

              > Is this valid XHTML? (inside the head-tag):

              > <script type="text/javascript">
              > function lt(a, b) {
              > return (a < b);
              > }
              > </script>

              Ill-formed.

              > nxml-mode complains about the "<" inside the javascript
              > function. The error is

              > `<' that is not markup must be entered as `<'

              > What should be done with this?

              What nXML is saying to you: replace '<' by '<'. This is not a
              markup character, it's a Javascript operator. So the XML parser must
              see the character entity call, to know it's not part of the markup.
              But Javascript will see a '<'.

              > Several php files I have seen use constructs like

              > <a href="<?php the_link() ?>">

              Ill-formed.

              > nxml-mode complains at "<a" with "Missing >" which seems
              > correct to me but is inconvenient. Is there some simple
              > way to allow < (or <?) inside attribute values?

              Nop. nXML is designed to parse XML. And all these are
              not well-formed XML.

              > Note that I am not thinking about modifying nxml-mode
              > (since several people have told me this is a very bad
              > idea), but rather a derived mode nxhtml-mode that I use.

              There was some discussion about that on the nXML ML. See
              the archives. IMHO, not a trivial task. You can search for "multiple
              major modes" in the archives, too.

              --drkm
























              ___________________________________________________________________________
              Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
              Téléchargez sur http://fr.messenger.yahoo.com
            • Florent Georges
              ... Which regexp? How do you modify it? Which version of nXML are you using? ... Which command did you try? Reagrds, --drkm
              Message 6 of 25 , Feb 7, 2006
              • 0 Attachment
                John Gage wrote:

                > In order for outline mode to work in nxml, I believe, out of
                > ignorance, that one must edit the default regex:

                Which regexp? How do you modify it? Which version of nXML are you
                using?

                > article\|\(sub\)*section\|chapter\|div\|appendix\|part\|preface\|
                > reference\|simplesect\|bibliography\|bibliodiv\|glossary\|glossdiv

                > to correspond to one's own tags <foo> <bar> etc.

                > I have done this, and I continue to get a "Not in section" error
                > whenever I try to use an outline command.

                Which command did you try?

                Reagrds,

                --drkm
























                ___________________________________________________________________________
                Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
                Téléchargez sur http://fr.messenger.yahoo.com
              • David Tolpin
                ... It won t, unfortunately. JavaScript in (X)HTML is handled for various reasons in such a way that < does not become
                Message 7 of 25 , Feb 7, 2006
                • 0 Attachment
                  > But Javascript will see a '<'.
                  >

                  It won't, unfortunately. JavaScript in (X)HTML is handled for various
                  reasons in such a way that < does not become <. Use JavaScript in
                  XML comments.
                • Reinout van Rees
                  ... At least within tal/metal attributes you can safely use < instead of the
                  Message 8 of 25 , Feb 7, 2006
                  • 0 Attachment
                    Victor Anyakin said:
                    > On Tue, Feb 07, 2006 at 12:49:16AM +0100, Lennart Borgman wrote:
                    >> Is this valid XHTML? (inside the head-tag):
                    >>
                    >> <script type="text/javascript">
                    >> function lt(a, b) {
                    >> return (a < b);
                    >> }
                    >> </script>
                    >>
                    >> nxml-mode complains about the "<" inside the javascript function. The
                    >> error is
                    >>
                    >> `<' that is not markup must be entered as `<'
                    >>
                    >> What should be done with this?
                    >
                    > I think, that nxml-mode is right. XML parser will treat "<" as a
                    > start-of-the-tag marker not as a less-than operator of the
                    > javascript.

                    At least within tal/metal attributes you can safely use < instead
                    of the '<'. It doesn't cause tal/metal to misbehave. I'd simply
                    try that for javascript too.

                    Alternatively, you can put the javascript in a separate file, of course.

                    Reinout

                    --
                    Reinout van Rees
                    reinout@... - http://vanrees.org/weblog/
                    "Keeping in step with the march of time" -- Arena
                  • Florent Georges
                    ... If you use XML,
                    Message 9 of 25 , Feb 7, 2006
                    • 0 Attachment
                      David Tolpin wrote:

                      > > But Javascript will see a '<'.

                      > It won't, unfortunately. JavaScript in (X)HTML is handled for
                      > various reasons in such a way that < does not become <.

                      If you use XML, '<' means '<' for the application, behind the XML
                      parser.

                      > Use JavaScript in XML comments.

                      Please don't do that. The parser is not obliged to return comments
                      to the user. The idiomatic way is to use CDATA like this:

                      <!-- I'm not sure for @type. -->
                      <script type="text/javascript">//<!CDATA[
                      ...
                      //]]>
                      </script>

                      Javascript comments are needed only if you want to be compatible with
                      HTML engines.

                      Regards,

                      --drkm
























                      ___________________________________________________________________________
                      Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
                      Téléchargez sur http://fr.messenger.yahoo.com
                    • Vincent Lefevre
                      ... It depends whether an XML or HTML (SGML) parser is used. -- Vincent Lefèvre - Web: 100% accessible validated
                      Message 10 of 25 , Feb 7, 2006
                      • 0 Attachment
                        On 2006-02-07 15:42:35 +0400, David Tolpin wrote:
                        > > But Javascript will see a '<'.
                        > >
                        >
                        > It won't, unfortunately. JavaScript in (X)HTML is handled for various
                        > reasons in such a way that < does not become <. Use JavaScript in
                        > XML comments.

                        It depends whether an XML or HTML (SGML) parser is used.

                        --
                        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
                      • David Tolpin
                        ... Florent, theory is great. The original poster asked about editing XHTML with nxml-mode. He also asked about php or something like that. If you use XHTML
                        Message 11 of 25 , Feb 7, 2006
                        • 0 Attachment
                          On 09/05/5766, at 16:19, Florent Georges wrote:

                          > David Tolpin wrote:
                          >
                          >>> But Javascript will see a '<'.
                          >
                          >> It won't, unfortunately. JavaScript in (X)HTML is handled for
                          >> various reasons in such a way that < does not become <.
                          >
                          > If you use XML, '<' means '<' for the application, behind the XML
                          > parser.

                          Florent,

                          theory is great. The original poster asked about editing XHTML with
                          nxml-mode. He also asked about php or something like that. If you use
                          XHTML for browsers and php or something like that, idiomatic ways
                          like CDATA and < don't work. JavaScript commenting does.

                          In general, JavaScript sucks, not just SGML parser legacy still used
                          for HTML. In practice, if you want JavaScript with XHTML, use
                          comments and not that great XML escaping.

                          David
                        • LENNART BORGMAN
                          Thanks for all the comments. In summary it looks like something like this must be used (if it should work both with nxml-mode and in a web browser):
                          Message 12 of 25 , Feb 7, 2006
                          • 0 Attachment
                            Thanks for all the comments. In summary it looks like something like this must be used (if it should work both with nxml-mode and in a web browser):

                            <script type="text/javascript>
                            <!--
                            if (a < b) ...
                            -->
                            </script>


                            ----- Original Message -----
                            From: David Tolpin <dvd@...>
                            Date: Tuesday, February 7, 2006 1:51 pm
                            Subject: Re: [emacs-nxml-mode] XHTML format and nxml-mode

                            >
                            > On 09/05/5766, at 16:19, Florent Georges wrote:
                            >
                            > > David Tolpin wrote:
                            > >
                            > >>> But Javascript will see a '<'.
                            > >
                            > >> It won't, unfortunately. JavaScript in (X)HTML is handled for
                            > >> various reasons in such a way that < does not become <.
                            > >
                            > > If you use XML, '<' means '<' for the application, behind the XML
                            > > parser.
                            >
                            > Florent,
                            >
                            > theory is great. The original poster asked about editing XHTML
                            > with
                            > nxml-mode. He also asked about php or something like that. If you
                            > use
                            > XHTML for browsers and php or something like that, idiomatic ways
                            > like CDATA and < don't work. JavaScript commenting does.
                            >
                            > In general, JavaScript sucks, not just SGML parser legacy still
                            > used
                            > for HTML. In practice, if you want JavaScript with XHTML, use
                            > comments and not that great XML escaping.
                            >
                            > David
                            >
                            >
                            >
                            >
                            >
                            > Yahoo! Groups Links
                            >
                            >
                            >
                            >
                            >
                            >
                            >
                            >
                          • David Tolpin
                            ... The javascript comment hides the XML end-of-comment from the HTML parser. David
                            Message 13 of 25 , Feb 7, 2006
                            • 0 Attachment
                              On 09/05/5766, at 17:01, LENNART BORGMAN wrote:

                              > Thanks for all the comments. In summary it looks like something
                              > like this must be used (if it should work both with nxml-mode and
                              > in a web browser):
                              >
                              > <script type="text/javascript>
                              > <!--
                              > if (a < b) ...
                              > -->
                              > </script>


                              <script type="text/javascript"><!--
                              if (a<b) a=b;
                              // -->
                              </script>

                              The javascript comment hides the XML end-of-comment from the HTML
                              parser.


                              David
                            • Florent Georges
                              ... Isn t it? But I don t speak in a theoretical level. If you re using an XML parser, you ll see
                              Message 14 of 25 , Feb 7, 2006
                              • 0 Attachment
                                David Tolpin wrote:

                                > On 09/05/5766, at 16:19, Florent Georges wrote:

                                > > If you use XML, '<' means '<' for the application,
                                > > behind the XML parser.

                                > theory is great.

                                Isn't it? But I don't speak in a theoretical level. If
                                you're using an XML parser, you'll see '<' in place of the
                                '<'. Just try it.

                                > The original poster asked about editing XHTML with
                                > nxml-mode. He also asked about php or something like
                                > that. If you use XHTML for browsers and php or something
                                > like that, idiomatic ways like CDATA and < don't
                                > work.

                                Can you please show an example?

                                > JavaScript commenting does.

                                I don't see what you mean.

                                > In general, JavaScript sucks, not just SGML parser legacy
                                > still used for HTML. In practice, if you want JavaScript
                                > with XHTML, use comments and not that great XML escaping.

                                Please, don't. Comments can be thrown away by the XML
                                parser. Tools that use comments to store data are a plea.

                                Regards,

                                --drkm























                                ___________________________________________________________________________
                                Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
                                Téléchargez sur http://fr.messenger.yahoo.com
                              • LENNART BORGMAN
                                Oh, sorry! Thanks for correcting me. ... From: David Tolpin Date: Tuesday, February 7, 2006 2:04 pm Subject: Re: [emacs-nxml-mode] XHTML
                                Message 15 of 25 , Feb 7, 2006
                                • 0 Attachment
                                  Oh, sorry! Thanks for correcting me.

                                  ----- Original Message -----
                                  From: David Tolpin <dvd@...>
                                  Date: Tuesday, February 7, 2006 2:04 pm
                                  Subject: Re: [emacs-nxml-mode] XHTML format and nxml-mode

                                  >
                                  > On 09/05/5766, at 17:01, LENNART BORGMAN wrote:
                                  >
                                  > > Thanks for all the comments. In summary it looks like something
                                  > > like this must be used (if it should work both with nxml-mode
                                  > and
                                  > > in a web browser):
                                  > >
                                  > > <script type="text/javascript>
                                  > > <!--
                                  > > if (a < b) ...
                                  > > -->
                                  > > </script>
                                  >
                                  >
                                  > <script type="text/javascript"><!--
                                  > if (a<b) a=b;
                                  > // -->
                                  > </script>
                                  >
                                  > The javascript comment hides the XML end-of-comment from the HTML
                                  > parser.
                                  >
                                  >
                                  > David
                                  >
                                  >
                                  >
                                  > Yahoo! Groups Links
                                  >
                                  >
                                  >
                                  >
                                  >
                                  >
                                  >
                                  >
                                • David Tolpin
                                  ... Easily. Try loading this: function greeting() { if(1<2) window.alert( hi ); }
                                  Message 16 of 25 , Feb 7, 2006
                                  • 0 Attachment
                                    >> that. If you use XHTML for browsers and php or something
                                    >> like that, idiomatic ways like CDATA and < don't
                                    >> work.
                                    >
                                    > Can you please show an example?


                                    Easily. Try loading this:

                                    <html>
                                    <head>
                                    <script type="text/javascript">
                                    function greeting() {
                                    if(1<2) window.alert("hi");
                                    }
                                    </script>
                                    </head>
                                    </html>

                                    into almost any browser, and look at the javascript console where it
                                    says that JavaScript has a parse error.

                                    >> JavaScript commenting does.
                                    >
                                    > I don't see what you mean.

                                    Putting JavaScript into SGML comments.

                                    > Please, don't. Comments can be thrown away by the XML
                                    > parser. Tools that use comments to store data are a plea.

                                    XML parsers are not used to parse HTML (including XHTML) in HTML
                                    browsers. Tools that use comments can be a plea, but humans are not.

                                    David
                                  • Florent Georges
                                    ... The problem is that is not guaranted to work, because it s really wrong. If a tool use an XML parser, it can not see the comment, because the parser can
                                    Message 17 of 25 , Feb 7, 2006
                                    • 0 Attachment
                                      LENNART BORGMAN wrote:

                                      > Thanks for all the comments. In summary it looks like something like
                                      > this must be used (if it should work both with nxml-mode and in a web
                                      > browser):

                                      > <script type="text/javascript>
                                      > <!--
                                      > if (a < b) ...
                                      > -->
                                      > </script>

                                      The problem is that is not guaranted to work, because it's really
                                      wrong. If a tool use an XML parser, it can not see the comment,
                                      because the parser can throw it away. The following is known to both
                                      work in practice and be correct in theory:

                                      <script type="text/javascript>
                                      //<![CDATA[
                                      if (a < b) ...
                                      //]]>
                                      </script>

                                      --drkm
























                                      ___________________________________________________________________________
                                      Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
                                      Téléchargez sur http://fr.messenger.yahoo.com
                                    • LENNART BORGMAN
                                      From: Florent Georges Date: Tuesday, February 7, 2006 2:25 pm Subject: Re: [emacs-nxml-mode] XHTML format and nxml-mode ... Ok, I see.
                                      Message 18 of 25 , Feb 7, 2006
                                      • 0 Attachment
                                        From: Florent Georges <darkman_spam@...>
                                        Date: Tuesday, February 7, 2006 2:25 pm
                                        Subject: Re: [emacs-nxml-mode] XHTML format and nxml-mode

                                        > LENNART BORGMAN wrote:
                                        >
                                        > > Thanks for all the comments. In summary it looks like something like
                                        > > this must be used (if it should work both with nxml-mode and in
                                        > a web
                                        > > browser):
                                        >
                                        > > <script type="text/javascript>
                                        > > <!--
                                        > > if (a < b) ...
                                        > > -->
                                        > > </script>
                                        >
                                        > The problem is that is not guaranted to work, because it's really
                                        > wrong. If a tool use an XML parser, it can not see the comment,
                                        > because the parser can throw it away. The following is known to both
                                        > work in practice and be correct in theory:
                                        >
                                        > <script type="text/javascript>
                                        > //<![CDATA[
                                        > if (a < b) ...
                                        > //]]>
                                        > </script>
                                        >
                                        > --drkm

                                        Ok, I see. I believed from earlier comments that the CDATA version did not work. But it does, at least in Firefox and IE.
                                      • Florent Georges
                                        ... Mmh. Sounds a little bit peremptory, sorry. But AFAIK CDATA is known to work in the browsers/SGML world, isn t it? While commenting will not always work
                                        Message 19 of 25 , Feb 7, 2006
                                        • 0 Attachment
                                          Florent Georges wrote:

                                          > > In general, JavaScript sucks, not just SGML parser legacy
                                          > > still used for HTML. In practice, if you want JavaScript
                                          > > with XHTML, use comments and not that great XML escaping.

                                          > Please, don't. Comments can be thrown away by the XML
                                          > parser. Tools that use comments to store data are a plea.

                                          Mmh. Sounds a little bit peremptory, sorry. But AFAIK CDATA is
                                          known to work in the browsers/SGML world, isn't it? While commenting
                                          will not always work in the XML world.

                                          If it's the case, as I think, why still use commenting now?

                                          Regards,

                                          --drkm























                                          ___________________________________________________________________________
                                          Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
                                          Téléchargez sur http://fr.messenger.yahoo.com
                                        • Vincent Lefevre
                                          ... This is OK with a SGML/HTML parser (in this context, this is not a comment), but not with a XML parser[*], where the comment will probably be removed,
                                          Message 20 of 25 , Feb 7, 2006
                                          • 0 Attachment
                                            On 2006-02-07 14:01:05 +0100, LENNART BORGMAN wrote:
                                            > Thanks for all the comments. In summary it looks like something like
                                            > this must be used (if it should work both with nxml-mode and in a
                                            > web browser):
                                            >
                                            > <script type="text/javascript>
                                            > <!--
                                            > if (a < b) ...
                                            > -->
                                            > </script>

                                            This is OK with a SGML/HTML parser (in this context, this is not
                                            a comment), but not with a XML parser[*], where the comment will
                                            probably be removed, therefore before the JS engine can see it.

                                            [*] Well, this is OK only for edition.

                                            --
                                            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
                                            ... First, this is not an XHTML file. ... No problem with Firefox. ... Modern browsers such as Firefox have an XML parser. -- Vincent Lefèvre
                                            Message 21 of 25 , Feb 7, 2006
                                            • 0 Attachment
                                              On 2006-02-07 17:22:22 +0400, David Tolpin wrote:
                                              > Easily. Try loading this:
                                              >
                                              > <html>
                                              > <head>
                                              > <script type="text/javascript">
                                              > function greeting() {
                                              > if(1<2) window.alert("hi");
                                              > }
                                              > </script>
                                              > </head>
                                              > </html>

                                              First, this is not an XHTML file.

                                              > into almost any browser, and look at the javascript console where it
                                              > says that JavaScript has a parse error.

                                              No problem with Firefox.

                                              > XML parsers are not used to parse HTML (including XHTML) in HTML
                                              > browsers. Tools that use comments can be a plea, but humans are not.

                                              Modern browsers such as Firefox have an XML parser.

                                              --
                                              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
                                              ... Like with Firefox (I ve just tried). With: //
                                              Message 22 of 25 , Feb 7, 2006
                                              • 0 Attachment
                                                On 2006-02-07 14:34:50 +0100, Florent Georges wrote:
                                                > Florent Georges wrote:
                                                >
                                                > > > In general, JavaScript sucks, not just SGML parser legacy
                                                > > > still used for HTML. In practice, if you want JavaScript
                                                > > > with XHTML, use comments and not that great XML escaping.
                                                >
                                                > > Please, don't. Comments can be thrown away by the XML
                                                > > parser. Tools that use comments to store data are a plea.
                                                >
                                                > Mmh. Sounds a little bit peremptory, sorry. But AFAIK CDATA is
                                                > known to work in the browsers/SGML world, isn't it? While commenting
                                                > will not always work in the XML world.

                                                Like with Firefox (I've just tried). With:

                                                <script type="text/javascript">
                                                //<!--
                                                function greeting() {
                                                if(1<2 bzz) window.alert("hi");
                                                }
                                                //-->
                                                </script>

                                                Firefox doesn't see any error. But if I remove both lines starting
                                                with //, I get in the JS console:

                                                Error: missing ) after condition
                                                Source File: http://vinc17.net4.nerim.net/~lefevre/test.xhtml
                                                Line: 6, Column: 16
                                                Source Code:
                                                if(1<2 bzz) window.alert("hi");

                                                --
                                                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 have entered this on the EmacsWiki: http://www.emacswiki.org/cgi-bin/wiki/NxmlModeForXHTML I prefer the other comment style (/* ... */) because this
                                                Message 23 of 25 , Feb 7, 2006
                                                • 0 Attachment
                                                  Florent Georges wrote:
                                                  > LENNART BORGMAN wrote:
                                                  >
                                                  >
                                                  >> Thanks for all the comments. In summary it looks like something like
                                                  >> this must be used (if it should work both with nxml-mode and in a web
                                                  >> browser):
                                                  >>
                                                  >
                                                  >
                                                  >> <script type="text/javascript>
                                                  >> <!--
                                                  >> if (a < b) ...
                                                  >> -->
                                                  >> </script>
                                                  >>
                                                  >
                                                  > The problem is that is not guaranted to work, because it's really
                                                  > wrong. If a tool use an XML parser, it can not see the comment,
                                                  > because the parser can throw it away. The following is known to both
                                                  > work in practice and be correct in theory:
                                                  >
                                                  > <script type="text/javascript>
                                                  > //<![CDATA[
                                                  > if (a < b) ...
                                                  > //]]>
                                                  > </script>
                                                  >
                                                  > --drkm
                                                  >

                                                  I have entered this on the EmacsWiki:
                                                  http://www.emacswiki.org/cgi-bin/wiki/NxmlModeForXHTML

                                                  I prefer the other comment style (/* ... */) because this should work
                                                  for inlined CSS in IE 6 too.
                                                • Florent Georges
                                                  ... Ok, I thought you spook about something special with PHP. But the solution I spook about is the one with CDATA. I don t see the advantage to use the
                                                  Message 24 of 25 , Feb 7, 2006
                                                  • 0 Attachment
                                                    David Tolpin wrote:

                                                    > >> that. If you use XHTML for browsers and php or something
                                                    > >> like that, idiomatic ways like CDATA and < don't
                                                    > >> work.

                                                    > > Can you please show an example?

                                                    > Easily. Try loading this:

                                                    > <html>
                                                    > <head>
                                                    > <script type="text/javascript">
                                                    > function greeting() {
                                                    > if(1<2) window.alert("hi");
                                                    > }
                                                    > </script>
                                                    > </head>
                                                    > </html>

                                                    Ok, I thought you spook about something special with PHP. But the
                                                    solution I spook about is the one with CDATA. I don't see the
                                                    advantage to use the comments in place of CDATA (but I see advantage to
                                                    use CDATA).

                                                    > > Please, don't. Comments can be thrown away by the XML
                                                    > > parser. Tools that use comments to store data are a plea.

                                                    > XML parsers are not used to parse HTML (including XHTML) in HTML
                                                    > browsers.

                                                    HTML browsers (and HTML browsers of beginning of 2006) are not the
                                                    only tools where we can have XHTML. The advantage of having XHTML is
                                                    also to can use any XML tool in the edition chain. BTW, the question
                                                    was regarding an XML edition tool, not an HTML browser.

                                                    So I think the question is: what's the advantage to still use (when
                                                    in addition we are explicitely using XML) comments for embedding
                                                    Javascript instead of CDATA sections?

                                                    Regards,

                                                    --drkm

























                                                    ___________________________________________________________________________
                                                    Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
                                                    Téléchargez sur http://fr.messenger.yahoo.com
                                                  • John Gage
                                                    It is best for me to quote from the instructions for nxml-outline mode to give an idea of what I am talking about. Incidentally, I think I may have been making
                                                    Message 25 of 25 , Feb 7, 2006
                                                    • 0 Attachment
                                                      It is best for me to quote from the instructions for nxml-outline
                                                      mode to give an idea of what I am talking about.

                                                      Incidentally, I think I may have been making a rather grotesque,
                                                      simple error, but perhaps not. Is it necessary to turn on the minor
                                                      outline mode to have outline work in nxml?

                                                      Here are the relevant parts of the documentation of nxml outline mode:

                                                      "Sections of the document can be displayed in outline form. The
                                                      variable `nxml-section-element-name-regexp' controls when an element
                                                      is recognized as a section...

                                                      Its value is
                                                      "article\\|\\(sub\\)*section\\|chapter\\|div\\|appendix\\|part\\|
                                                      preface\\|reference\\|simplesect\\|bibliography\\|bibliodiv\\|glossary
                                                      \\|glossdiv":

                                                      a regular expression matching the name of elements used as sections.
                                                      An XML element is treated as a section if:

                                                      - its local name (that is, the name without the prefix) matches
                                                      this regexp;

                                                      - either its first child element or a descendant of that first child
                                                      element has a local name matching the variable
                                                      `nxml-heading-element-name-regexp'; and

                                                      - its start-tag occurs at the beginning of a line (possibly indented)."

                                                      It would seem one has to write one's own regex to match one's section
                                                      names if they are not included in the regex above. I have done this
                                                      with customization and continue to get the error "No in a section"
                                                      which is generated by the following code:

                                                      (defun nxml-section-start-position ()
                                                      "Return the position of the start of the section containing point.
                                                      Signal an error on failure."
                                                      (condition-case err
                                                      (save-excursion (if (nxml-back-to-section-start)
                                                      (point)
                                                      (error "Not in section")))
                                                      (nxml-outline-error
                                                      (nxml-report-outline-error "Couldn't determine containing
                                                      section: %s"
                                                      err))))

                                                      I have positioned the point just about everywhere I can think of,
                                                      but it doesn't seem to work.

                                                      John

                                                      On Feb 7, 2006, at 12:42 PM, Florent Georges wrote:


                                                      > John Gage wrote:
                                                      >
                                                      > > In order for outline mode to work in nxml, I believe, out of
                                                      > > ignorance, that one must edit the default regex:
                                                      >
                                                      > Which regexp? How do you modify it? Which version of nXML are you
                                                      > using?
                                                      >
                                                      > > article\|\(sub\)*section\|chapter\|div\|appendix\|part\|preface\|
                                                      > > reference\|simplesect\|bibliography\|bibliodiv\|glossary\|glossdiv
                                                      >
                                                      > > to correspond to one's own tags <foo> <bar> etc.
                                                      >
                                                      > > I have done this, and I continue to get a "Not in section" error
                                                      > > whenever I try to use an outline command.
                                                      >
                                                      > Which command did you try?
                                                      >
                                                      > Reagrds,
                                                      >
                                                      > --drkm
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      >
                                                      > ______________________________________________________________________
                                                      > _____
                                                      > Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez
                                                      > les tarifs exceptionnels pour appeler la France et l'international.
                                                      > Téléchargez sur http://fr.messenger.yahoo.com
                                                      >
                                                      >
                                                      > SPONSORED LINKS
                                                      > Computer internet security Computer internet business Computer
                                                      > internet access
                                                      > Computer internet privacy securities Computer internet help Xml
                                                      > development
                                                      >
                                                      > YAHOO! GROUPS LINKS
                                                      >
                                                      > Visit your group "emacs-nxml-mode" on the web.
                                                      >
                                                      > To unsubscribe from this group, send an email to:
                                                      > emacs-nxml-mode-unsubscribe@yahoogroups.com
                                                      >
                                                      > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
                                                      >
                                                      >
                                                    Your message has been successfully submitted and would be delivered to recipients shortly.