0

I am documenting several large XSLT scripts using the \lstinputlisting command. I have set Processing Instructions in the scripts to mark off suitably-sized blocks of code to document, mostly 10–20 lines each block, in the format

<?doc val1?>

and

<?doc val2?>

(etc; many dozens of these) and included the options rangeprefix=\<?doc\ ,rangesuffix=?\>,linerange=val1-val2

After the first code block has been done (correctly), it stops recognising the PI pattern and just includes all of the rest of the script to the end of the file, even displaying the PIs that it was supposed to have recognised.

These scripts are not mine to publish here, but before I try to construct a MWE, I wanted to know if anyone else has hit this problem. It only seems to occur with larger files (the current problematic one is 92KB and 2330 lines).

This happens with both pdflatex Version 3.14159265-2.6-1.40.16 and XeLaTeX Version 3.14159265-2.6-0.99992, both with LaTeX <2016/02/01> and listings.sty 1.6 (2015/06/04)

EDITED 2018-11-27

Here is the MWE (now using cpdoc instead of doc as the PI name):

\documentclass{article}
\usepackage{listings}
\begin{document}
\section{Start}

\lstinputlisting[language=XSLT,
  rangeprefix=\<?cpdoc\ ,rangesuffix=?\>,
  linerange=start-components,includerangemarker=false,
  showlines=false]{sitemap.xmap}

\section{Components}

\lstinputlisting[language=XSLT,
  rangeprefix=\<?cpdoc\ ,rangesuffix=?\>,
  linerange=components-generators,includerangemarker=false,
  showlines=false]{sitemap.xmap}

\end{document}

and here is the file sitemap.xmap to go with it.

<?cpdoc start?>
<?xml version="1.0" encoding="UTF-8"?><!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!--+
    | This is the 'heart' of Cocoon. The sitemap maps URI space to
    | resources. It consists basicaly of two parts: components and
    | pipelines. Pipelines are made out of components. There is such a
    | vast number of components available that it would be impossible to
    | describe them here, please refer to the accompanying
    | documentation. For specific components, have a look also at the
    | javadocs for them. Most pipelines are present to demonstrate some
    | feature or technique, often they are explained in more detail in
    | the accompanying documentation. The sitemaps which come with each
    | sample and each block will help to explain.
    |
    | CVS $Id: sitemap.xmap 477161 2006-11-20 12:25:52Z jeremy $
    +--><map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<?cpdoc components?>
<!-- ======================= Components ================================ -->

  <map:components>

  <!--+
      | All pipelines consist at least of two components: a generator, that
      | produces the content, and a serialiser, that delivers the content to
      | the client.
      |
      | More precisely: a generator generates SAX events and a serializer
      | consumes these events and produces a byte stream.
      |
      | Some things to note here: each generator has a unique name, this
      | name is mapped to a java class, one name is declared as the default
      | generator. Each generator may have additional configurations as
      | child elements.
      |
      | Additional attributes are targeted at the component manager. The optional
      | "label" attribute is relevant for the view concept below. The optional
      | "logger" attribute defines the logging category where messages produced
      | by a component should go. If there's no "logger" attribute, the category
      | used is the one defined for the "sitemap" component in cocoon.xconf.
      |
      | We have chosen in this sitemap to use a different logging category
      | for each component, which allows fine-grained classification of log
      | messages. But you are free to use any category you want.
      |
      | It is possible to have the same java class declared as different
      | generators by using different names. No configuration options are
      | shared between these instances, however.
      |
      | All components follow this scheme.
      +-->
<?cpdoc generators?>
  <map:generators default="file">
    <map:generator label="content" logger="sitemap.generator.file" name="file" pool-max="${file-generator.pool-max}" src="org.apache.cocoon.generation.FileGenerator"/>
  </map:generators>

</map:sitemap>

The output PDF looks like this (p.1 as JPG): you can see the PI for 'components' being included in the output instead of being recognised as a boundary JPG of p.1 of output PDF

  • 1
    Can you post a complete minimal working example, including an XSLT file? – Andrew Nov 25 '18 at 2:12
  • As I said, I'm waiting to see if anyone recognises the problem first. I will then need to find a public script of the same size to use. – Peter Flynn Nov 25 '18 at 13:06
  • I added a MWE and an XSLT file to demonstrate the problem. – Peter Flynn Nov 28 '18 at 12:02
  • Is anyone able to replicate this? – Peter Flynn Dec 1 '18 at 21:31
1

Not a real solution but too long for a comment. It looks as if the comment starting at the line behind the marker is putting listings out of the track. If I move this comment in line down, or add an empty line after the marker it works again. It also works if one use includerangemarker=true. I would suggest to write the author a bug report.

\documentclass{article}
\usepackage{listings}
\begin{document}
\section{Work}

\lstinputlisting[language=XSLT,
  rangeprefix={<?cpdoc\ },rangesuffix={?>},
  linerange=startB-componentsB,includerangemarker=false,
  showlines=false]{sitemap.xml}

\section{Work}

\lstinputlisting[language=XSLT,
  rangeprefix={<?cpdoc\ },rangesuffix={?>},
  linerange=startC-componentsC,includerangemarker=false,
  showlines=false]{sitemap.xml}

\section{Fail}
\lstinputlisting[language=XSLT,
  rangeprefix={<?cpdoc\ },rangesuffix={?>},
  linerange=start-components,includerangemarker=false,
  showlines=false]{sitemap.xml}

\end{document}

With this sitemap.xml:

<?cpdoc start?>
<?xml version="1.0" encoding="UTF-8"?><!--
  Licensed to the Apache Software Foundation (ASF) under one or more
-->
<?cpdoc components?>

<?cpdoc startB?>
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
-->
<?cpdoc componentsB?>


<?cpdoc startC?>

<?xml version="1.0" encoding="UTF-8"?><!--
  Licensed to the Apache Software Foundation (ASF) under one or more
-->
<?cpdoc componentsC?>

enter image description here

The problem can be reduced to using a tag with the aspect html:

\documentclass{article}
\usepackage{listings}

\lstdefinelanguage{XMLNEW}{tag=**[s]<>}[html]%

\begin{document}
\section{Fail}
\lstinputlisting[language=XMLNEW,
  rangeprefix={<?cpdoc\ },rangesuffix={?>},
  linerange=start-components,includerangemarker=false,
  showlines=false]{sitemap.xml}

\end{document}
  • Thank you very much...I did try removing the comments from one of the user's live XML documents but it had no effect, so I need to work harder on this. I also have some shorted files which work with comments after the line range markers. Very weird. – Peter Flynn Dec 6 '18 at 21:59
  • I have submitted a bug report. Thanks for your help. – Peter Flynn Dec 9 '18 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.