ConTeXt XML: Nested section elements












5















I am trying to produce PDF from XML with ConTeXt. Currently, I am struggling with this: The XML file is in JATS, and JATS usually does not specify the levels of sections. There is an optional attribute disp-level that I have used until now, but it turns out that this attribute is often ommitted. This means I have to guess at which section level we are at. In order to do I have tried checking how far we are away from <body>: If <body> is the parent of the current element the current element's level is section, if it is the parent of the parent of the current element the current element's level is subsection, and so on.



startbuffer[test]
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
"JATS-journalpublishing1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
<front>
</front>
<body>
<sec id="section-heading">
<title>Section Heading</title>
<p>Some Text</p>
<sec id="subsection-heading">
<title>Subsection Heading</title>
<p>More Text</p>
</sec>
</sec>
</body>
<back>
</back>
</article>
stopbuffer

startxmlsetups xml:jatssetups
xmlsetsetup{#1}{*}{-}
xmlsetsetup{#1}{article|body|sec|p}{xml:*}
stopxmlsetups

xmlregistersetup{xml:jatssetups}

startxmlsetups xml:article
xmlflush{#1}
stopxmlsetups

startxmlsetups xml:body
startdocument
xmlflush{#1}
stopdocument
stopxmlsetups

startxmlsetups xml:p
xmlflush{#1}par
stopxmlsetups

% Sections

startxmlsetups xml:sec
xmlfilter{#1}{../../body/command(xml:sec:section)}
stopxmlsetups

startxmlsetups xml:sec:section
startsection[title=xmlfirst{#1}{/title}]
xmlall{#1}{/!title}
stopsection
stopxmlsetups

startxmlsetups xml:sec:subsection
startsubsection[title=xmlfirst{#1}{/title}]
xmlall{#1}{/!title}
stopsubsection
stopxmlsetups


xmlprocessbuffer{main}{test}{}


However, this produces an fatal error ("TeX capacity exceeded."). Perhaps someone has a better idea?










share|improve this question















This question has an open bounty worth +50
reputation from Henri Menke ending in 5 days.


One or more of the answers is exemplary and worthy of an additional bounty.





















    5















    I am trying to produce PDF from XML with ConTeXt. Currently, I am struggling with this: The XML file is in JATS, and JATS usually does not specify the levels of sections. There is an optional attribute disp-level that I have used until now, but it turns out that this attribute is often ommitted. This means I have to guess at which section level we are at. In order to do I have tried checking how far we are away from <body>: If <body> is the parent of the current element the current element's level is section, if it is the parent of the parent of the current element the current element's level is subsection, and so on.



    startbuffer[test]
    <?xml version="1.0" encoding="utf-8" ?>
    <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
    "JATS-journalpublishing1.dtd">
    <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
    <front>
    </front>
    <body>
    <sec id="section-heading">
    <title>Section Heading</title>
    <p>Some Text</p>
    <sec id="subsection-heading">
    <title>Subsection Heading</title>
    <p>More Text</p>
    </sec>
    </sec>
    </body>
    <back>
    </back>
    </article>
    stopbuffer

    startxmlsetups xml:jatssetups
    xmlsetsetup{#1}{*}{-}
    xmlsetsetup{#1}{article|body|sec|p}{xml:*}
    stopxmlsetups

    xmlregistersetup{xml:jatssetups}

    startxmlsetups xml:article
    xmlflush{#1}
    stopxmlsetups

    startxmlsetups xml:body
    startdocument
    xmlflush{#1}
    stopdocument
    stopxmlsetups

    startxmlsetups xml:p
    xmlflush{#1}par
    stopxmlsetups

    % Sections

    startxmlsetups xml:sec
    xmlfilter{#1}{../../body/command(xml:sec:section)}
    stopxmlsetups

    startxmlsetups xml:sec:section
    startsection[title=xmlfirst{#1}{/title}]
    xmlall{#1}{/!title}
    stopsection
    stopxmlsetups

    startxmlsetups xml:sec:subsection
    startsubsection[title=xmlfirst{#1}{/title}]
    xmlall{#1}{/!title}
    stopsubsection
    stopxmlsetups


    xmlprocessbuffer{main}{test}{}


    However, this produces an fatal error ("TeX capacity exceeded."). Perhaps someone has a better idea?










    share|improve this question















    This question has an open bounty worth +50
    reputation from Henri Menke ending in 5 days.


    One or more of the answers is exemplary and worthy of an additional bounty.



















      5












      5








      5








      I am trying to produce PDF from XML with ConTeXt. Currently, I am struggling with this: The XML file is in JATS, and JATS usually does not specify the levels of sections. There is an optional attribute disp-level that I have used until now, but it turns out that this attribute is often ommitted. This means I have to guess at which section level we are at. In order to do I have tried checking how far we are away from <body>: If <body> is the parent of the current element the current element's level is section, if it is the parent of the parent of the current element the current element's level is subsection, and so on.



      startbuffer[test]
      <?xml version="1.0" encoding="utf-8" ?>
      <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
      "JATS-journalpublishing1.dtd">
      <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
      <front>
      </front>
      <body>
      <sec id="section-heading">
      <title>Section Heading</title>
      <p>Some Text</p>
      <sec id="subsection-heading">
      <title>Subsection Heading</title>
      <p>More Text</p>
      </sec>
      </sec>
      </body>
      <back>
      </back>
      </article>
      stopbuffer

      startxmlsetups xml:jatssetups
      xmlsetsetup{#1}{*}{-}
      xmlsetsetup{#1}{article|body|sec|p}{xml:*}
      stopxmlsetups

      xmlregistersetup{xml:jatssetups}

      startxmlsetups xml:article
      xmlflush{#1}
      stopxmlsetups

      startxmlsetups xml:body
      startdocument
      xmlflush{#1}
      stopdocument
      stopxmlsetups

      startxmlsetups xml:p
      xmlflush{#1}par
      stopxmlsetups

      % Sections

      startxmlsetups xml:sec
      xmlfilter{#1}{../../body/command(xml:sec:section)}
      stopxmlsetups

      startxmlsetups xml:sec:section
      startsection[title=xmlfirst{#1}{/title}]
      xmlall{#1}{/!title}
      stopsection
      stopxmlsetups

      startxmlsetups xml:sec:subsection
      startsubsection[title=xmlfirst{#1}{/title}]
      xmlall{#1}{/!title}
      stopsubsection
      stopxmlsetups


      xmlprocessbuffer{main}{test}{}


      However, this produces an fatal error ("TeX capacity exceeded."). Perhaps someone has a better idea?










      share|improve this question














      I am trying to produce PDF from XML with ConTeXt. Currently, I am struggling with this: The XML file is in JATS, and JATS usually does not specify the levels of sections. There is an optional attribute disp-level that I have used until now, but it turns out that this attribute is often ommitted. This means I have to guess at which section level we are at. In order to do I have tried checking how far we are away from <body>: If <body> is the parent of the current element the current element's level is section, if it is the parent of the parent of the current element the current element's level is subsection, and so on.



      startbuffer[test]
      <?xml version="1.0" encoding="utf-8" ?>
      <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
      "JATS-journalpublishing1.dtd">
      <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
      <front>
      </front>
      <body>
      <sec id="section-heading">
      <title>Section Heading</title>
      <p>Some Text</p>
      <sec id="subsection-heading">
      <title>Subsection Heading</title>
      <p>More Text</p>
      </sec>
      </sec>
      </body>
      <back>
      </back>
      </article>
      stopbuffer

      startxmlsetups xml:jatssetups
      xmlsetsetup{#1}{*}{-}
      xmlsetsetup{#1}{article|body|sec|p}{xml:*}
      stopxmlsetups

      xmlregistersetup{xml:jatssetups}

      startxmlsetups xml:article
      xmlflush{#1}
      stopxmlsetups

      startxmlsetups xml:body
      startdocument
      xmlflush{#1}
      stopdocument
      stopxmlsetups

      startxmlsetups xml:p
      xmlflush{#1}par
      stopxmlsetups

      % Sections

      startxmlsetups xml:sec
      xmlfilter{#1}{../../body/command(xml:sec:section)}
      stopxmlsetups

      startxmlsetups xml:sec:section
      startsection[title=xmlfirst{#1}{/title}]
      xmlall{#1}{/!title}
      stopsection
      stopxmlsetups

      startxmlsetups xml:sec:subsection
      startsubsection[title=xmlfirst{#1}{/title}]
      xmlall{#1}{/!title}
      stopsubsection
      stopxmlsetups


      xmlprocessbuffer{main}{test}{}


      However, this produces an fatal error ("TeX capacity exceeded."). Perhaps someone has a better idea?







      sectioning context xml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 8 at 15:15









      DenisDenis

      424210




      424210






      This question has an open bounty worth +50
      reputation from Henri Menke ending in 5 days.


      One or more of the answers is exemplary and worthy of an additional bounty.








      This question has an open bounty worth +50
      reputation from Henri Menke ending in 5 days.


      One or more of the answers is exemplary and worthy of an additional bounty.
























          2 Answers
          2






          active

          oldest

          votes


















          5














          One option is to map the <section> tags to startsectionlevel macros, which can be nested:



          starttext
          startstructurelevel[title=Section heading]
          Some text
          startstructurelevel[title=Subsection heading]
          More text
          stopstructurelevel
          stopstructurelevel
          stoptext


          The default mapping is that the first level maps to a chapter, the second level maps to a section, and so on. You can change this setting using:



          definesectionlevels
          [default]
          [
          section,
          subsection,
          subsubsection,
          subsubsubsection,
          ]


          With the above setup, the first level startstructurelevel is mapped to startsection, the second level startstructurelevel is mapped to startsubsection and so on until four nested levels.



          You can change the style of the document using normal setup commands that change the style of startsection etc. Here is an example:



          definesectionlevels
          [default]
          [
          section,
          subsection,
          subsubsection,
          subsubsubsection,
          ]

          setuphead[section][color=blue]
          setuphead[subsection][color=red]

          starttext
          startstructurelevel[title=Section heading]
          Some text
          startstructurelevel[title=Subsection heading]
          More text
          stopstructurelevel
          stopstructurelevel
          stoptext


          which gives



          enter image description here






          share|improve this answer


























          • Oh, that looks interesting. I gave it a quick try and it seems to work. However, I cannot find information about this command on the wiki, so I'd be happy to learn more about how it works. Especially since my setuphead definititions don't seem to affect this command. In any case, I'd still love to learn about how to use xmlfilters correctly.

            – Denis
            Feb 8 at 18:44













          • @Denis I added some more details about strartstructurelevel. It is a synonym of startsectionlevel, so you can search for both keywords

            – Aditya
            2 days ago



















          2














          Based on Aditya's input I can now come up with this solution:



          startbuffer[test]
          <?xml version="1.0" encoding="utf-8" ?>
          <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
          "JATS-journalpublishing1.dtd">
          <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
          <front>
          </front>
          <body>
          <sec id="section-heading">
          <title>Section Heading</title>
          <p>Some Text</p>
          <sec id="subsection-heading">
          <title>Subsection Heading</title>
          <p>More Text</p>
          </sec>
          </sec>
          </body>
          <back>
          </back>
          </article>
          stopbuffer

          startxmlsetups xml:jatssetups
          xmlsetsetup{#1}{*}{-}
          xmlsetsetup{#1}{article|body|sec|p}{xml:*}
          stopxmlsetups

          xmlregistersetup{xml:jatssetups}

          startxmlsetups xml:article
          xmlflush{#1}
          stopxmlsetups

          startxmlsetups xml:body
          startdocument
          xmlflush{#1}
          stopdocument
          stopxmlsetups

          startxmlsetups xml:p
          xmlflush{#1}par
          stopxmlsetups

          % Sections

          startxmlsetups xml:sec
          startstructurelevel [title=xmlfilter{#1}{/title/command(xml:sec:title)}]
          xmlflush{#1}
          stopstructurelevel
          stopxmlsetups

          startxmlsetups xml:sec:title
          xmlflush{#1}
          stopxmlsetups

          definestructurelevels [default] [section,subsection,subsubsection]
          setuphead [section] [style=bf]
          setuphead [subsection] [style=em]


          xmlprocessbuffer{main}{test}{}





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "85"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473940%2fcontext-xml-nested-section-elements%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            5














            One option is to map the <section> tags to startsectionlevel macros, which can be nested:



            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            The default mapping is that the first level maps to a chapter, the second level maps to a section, and so on. You can change this setting using:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]


            With the above setup, the first level startstructurelevel is mapped to startsection, the second level startstructurelevel is mapped to startsubsection and so on until four nested levels.



            You can change the style of the document using normal setup commands that change the style of startsection etc. Here is an example:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]

            setuphead[section][color=blue]
            setuphead[subsection][color=red]

            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            which gives



            enter image description here






            share|improve this answer


























            • Oh, that looks interesting. I gave it a quick try and it seems to work. However, I cannot find information about this command on the wiki, so I'd be happy to learn more about how it works. Especially since my setuphead definititions don't seem to affect this command. In any case, I'd still love to learn about how to use xmlfilters correctly.

              – Denis
              Feb 8 at 18:44













            • @Denis I added some more details about strartstructurelevel. It is a synonym of startsectionlevel, so you can search for both keywords

              – Aditya
              2 days ago
















            5














            One option is to map the <section> tags to startsectionlevel macros, which can be nested:



            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            The default mapping is that the first level maps to a chapter, the second level maps to a section, and so on. You can change this setting using:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]


            With the above setup, the first level startstructurelevel is mapped to startsection, the second level startstructurelevel is mapped to startsubsection and so on until four nested levels.



            You can change the style of the document using normal setup commands that change the style of startsection etc. Here is an example:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]

            setuphead[section][color=blue]
            setuphead[subsection][color=red]

            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            which gives



            enter image description here






            share|improve this answer


























            • Oh, that looks interesting. I gave it a quick try and it seems to work. However, I cannot find information about this command on the wiki, so I'd be happy to learn more about how it works. Especially since my setuphead definititions don't seem to affect this command. In any case, I'd still love to learn about how to use xmlfilters correctly.

              – Denis
              Feb 8 at 18:44













            • @Denis I added some more details about strartstructurelevel. It is a synonym of startsectionlevel, so you can search for both keywords

              – Aditya
              2 days ago














            5












            5








            5







            One option is to map the <section> tags to startsectionlevel macros, which can be nested:



            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            The default mapping is that the first level maps to a chapter, the second level maps to a section, and so on. You can change this setting using:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]


            With the above setup, the first level startstructurelevel is mapped to startsection, the second level startstructurelevel is mapped to startsubsection and so on until four nested levels.



            You can change the style of the document using normal setup commands that change the style of startsection etc. Here is an example:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]

            setuphead[section][color=blue]
            setuphead[subsection][color=red]

            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            which gives



            enter image description here






            share|improve this answer















            One option is to map the <section> tags to startsectionlevel macros, which can be nested:



            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            The default mapping is that the first level maps to a chapter, the second level maps to a section, and so on. You can change this setting using:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]


            With the above setup, the first level startstructurelevel is mapped to startsection, the second level startstructurelevel is mapped to startsubsection and so on until four nested levels.



            You can change the style of the document using normal setup commands that change the style of startsection etc. Here is an example:



            definesectionlevels
            [default]
            [
            section,
            subsection,
            subsubsection,
            subsubsubsection,
            ]

            setuphead[section][color=blue]
            setuphead[subsection][color=red]

            starttext
            startstructurelevel[title=Section heading]
            Some text
            startstructurelevel[title=Subsection heading]
            More text
            stopstructurelevel
            stopstructurelevel
            stoptext


            which gives



            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 2 days ago

























            answered Feb 8 at 16:51









            AdityaAditya

            55.4k2109236




            55.4k2109236













            • Oh, that looks interesting. I gave it a quick try and it seems to work. However, I cannot find information about this command on the wiki, so I'd be happy to learn more about how it works. Especially since my setuphead definititions don't seem to affect this command. In any case, I'd still love to learn about how to use xmlfilters correctly.

              – Denis
              Feb 8 at 18:44













            • @Denis I added some more details about strartstructurelevel. It is a synonym of startsectionlevel, so you can search for both keywords

              – Aditya
              2 days ago



















            • Oh, that looks interesting. I gave it a quick try and it seems to work. However, I cannot find information about this command on the wiki, so I'd be happy to learn more about how it works. Especially since my setuphead definititions don't seem to affect this command. In any case, I'd still love to learn about how to use xmlfilters correctly.

              – Denis
              Feb 8 at 18:44













            • @Denis I added some more details about strartstructurelevel. It is a synonym of startsectionlevel, so you can search for both keywords

              – Aditya
              2 days ago

















            Oh, that looks interesting. I gave it a quick try and it seems to work. However, I cannot find information about this command on the wiki, so I'd be happy to learn more about how it works. Especially since my setuphead definititions don't seem to affect this command. In any case, I'd still love to learn about how to use xmlfilters correctly.

            – Denis
            Feb 8 at 18:44







            Oh, that looks interesting. I gave it a quick try and it seems to work. However, I cannot find information about this command on the wiki, so I'd be happy to learn more about how it works. Especially since my setuphead definititions don't seem to affect this command. In any case, I'd still love to learn about how to use xmlfilters correctly.

            – Denis
            Feb 8 at 18:44















            @Denis I added some more details about strartstructurelevel. It is a synonym of startsectionlevel, so you can search for both keywords

            – Aditya
            2 days ago





            @Denis I added some more details about strartstructurelevel. It is a synonym of startsectionlevel, so you can search for both keywords

            – Aditya
            2 days ago











            2














            Based on Aditya's input I can now come up with this solution:



            startbuffer[test]
            <?xml version="1.0" encoding="utf-8" ?>
            <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
            "JATS-journalpublishing1.dtd">
            <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
            <front>
            </front>
            <body>
            <sec id="section-heading">
            <title>Section Heading</title>
            <p>Some Text</p>
            <sec id="subsection-heading">
            <title>Subsection Heading</title>
            <p>More Text</p>
            </sec>
            </sec>
            </body>
            <back>
            </back>
            </article>
            stopbuffer

            startxmlsetups xml:jatssetups
            xmlsetsetup{#1}{*}{-}
            xmlsetsetup{#1}{article|body|sec|p}{xml:*}
            stopxmlsetups

            xmlregistersetup{xml:jatssetups}

            startxmlsetups xml:article
            xmlflush{#1}
            stopxmlsetups

            startxmlsetups xml:body
            startdocument
            xmlflush{#1}
            stopdocument
            stopxmlsetups

            startxmlsetups xml:p
            xmlflush{#1}par
            stopxmlsetups

            % Sections

            startxmlsetups xml:sec
            startstructurelevel [title=xmlfilter{#1}{/title/command(xml:sec:title)}]
            xmlflush{#1}
            stopstructurelevel
            stopxmlsetups

            startxmlsetups xml:sec:title
            xmlflush{#1}
            stopxmlsetups

            definestructurelevels [default] [section,subsection,subsubsection]
            setuphead [section] [style=bf]
            setuphead [subsection] [style=em]


            xmlprocessbuffer{main}{test}{}





            share|improve this answer




























              2














              Based on Aditya's input I can now come up with this solution:



              startbuffer[test]
              <?xml version="1.0" encoding="utf-8" ?>
              <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
              "JATS-journalpublishing1.dtd">
              <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
              <front>
              </front>
              <body>
              <sec id="section-heading">
              <title>Section Heading</title>
              <p>Some Text</p>
              <sec id="subsection-heading">
              <title>Subsection Heading</title>
              <p>More Text</p>
              </sec>
              </sec>
              </body>
              <back>
              </back>
              </article>
              stopbuffer

              startxmlsetups xml:jatssetups
              xmlsetsetup{#1}{*}{-}
              xmlsetsetup{#1}{article|body|sec|p}{xml:*}
              stopxmlsetups

              xmlregistersetup{xml:jatssetups}

              startxmlsetups xml:article
              xmlflush{#1}
              stopxmlsetups

              startxmlsetups xml:body
              startdocument
              xmlflush{#1}
              stopdocument
              stopxmlsetups

              startxmlsetups xml:p
              xmlflush{#1}par
              stopxmlsetups

              % Sections

              startxmlsetups xml:sec
              startstructurelevel [title=xmlfilter{#1}{/title/command(xml:sec:title)}]
              xmlflush{#1}
              stopstructurelevel
              stopxmlsetups

              startxmlsetups xml:sec:title
              xmlflush{#1}
              stopxmlsetups

              definestructurelevels [default] [section,subsection,subsubsection]
              setuphead [section] [style=bf]
              setuphead [subsection] [style=em]


              xmlprocessbuffer{main}{test}{}





              share|improve this answer


























                2












                2








                2







                Based on Aditya's input I can now come up with this solution:



                startbuffer[test]
                <?xml version="1.0" encoding="utf-8" ?>
                <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
                "JATS-journalpublishing1.dtd">
                <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
                <front>
                </front>
                <body>
                <sec id="section-heading">
                <title>Section Heading</title>
                <p>Some Text</p>
                <sec id="subsection-heading">
                <title>Subsection Heading</title>
                <p>More Text</p>
                </sec>
                </sec>
                </body>
                <back>
                </back>
                </article>
                stopbuffer

                startxmlsetups xml:jatssetups
                xmlsetsetup{#1}{*}{-}
                xmlsetsetup{#1}{article|body|sec|p}{xml:*}
                stopxmlsetups

                xmlregistersetup{xml:jatssetups}

                startxmlsetups xml:article
                xmlflush{#1}
                stopxmlsetups

                startxmlsetups xml:body
                startdocument
                xmlflush{#1}
                stopdocument
                stopxmlsetups

                startxmlsetups xml:p
                xmlflush{#1}par
                stopxmlsetups

                % Sections

                startxmlsetups xml:sec
                startstructurelevel [title=xmlfilter{#1}{/title/command(xml:sec:title)}]
                xmlflush{#1}
                stopstructurelevel
                stopxmlsetups

                startxmlsetups xml:sec:title
                xmlflush{#1}
                stopxmlsetups

                definestructurelevels [default] [section,subsection,subsubsection]
                setuphead [section] [style=bf]
                setuphead [subsection] [style=em]


                xmlprocessbuffer{main}{test}{}





                share|improve this answer













                Based on Aditya's input I can now come up with this solution:



                startbuffer[test]
                <?xml version="1.0" encoding="utf-8" ?>
                <!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.0 20120330//EN"
                "JATS-journalpublishing1.dtd">
                <article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="1.0" article-type="other">
                <front>
                </front>
                <body>
                <sec id="section-heading">
                <title>Section Heading</title>
                <p>Some Text</p>
                <sec id="subsection-heading">
                <title>Subsection Heading</title>
                <p>More Text</p>
                </sec>
                </sec>
                </body>
                <back>
                </back>
                </article>
                stopbuffer

                startxmlsetups xml:jatssetups
                xmlsetsetup{#1}{*}{-}
                xmlsetsetup{#1}{article|body|sec|p}{xml:*}
                stopxmlsetups

                xmlregistersetup{xml:jatssetups}

                startxmlsetups xml:article
                xmlflush{#1}
                stopxmlsetups

                startxmlsetups xml:body
                startdocument
                xmlflush{#1}
                stopdocument
                stopxmlsetups

                startxmlsetups xml:p
                xmlflush{#1}par
                stopxmlsetups

                % Sections

                startxmlsetups xml:sec
                startstructurelevel [title=xmlfilter{#1}{/title/command(xml:sec:title)}]
                xmlflush{#1}
                stopstructurelevel
                stopxmlsetups

                startxmlsetups xml:sec:title
                xmlflush{#1}
                stopxmlsetups

                definestructurelevels [default] [section,subsection,subsubsection]
                setuphead [section] [style=bf]
                setuphead [subsection] [style=em]


                xmlprocessbuffer{main}{test}{}






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 19 hours ago









                DenisDenis

                424210




                424210






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473940%2fcontext-xml-nested-section-elements%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

                    ComboBox Display Member on multiple fields

                    Is it possible to collect Nectar points via Trainline?