Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF: "NOTE" and "NOTE X" labels runs into content #522

Closed
ronaldtse opened this issue Mar 28, 2023 · 16 comments
Closed

PDF: "NOTE" and "NOTE X" labels runs into content #522

ronaldtse opened this issue Mar 28, 2023 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@ronaldtse
Copy link
Contributor

ronaldtse commented Mar 28, 2023

Screenshot 2023-03-29 at 12 22 50 AM

Screenshot 2023-03-29 at 12 25 14 AM

@ronaldtse ronaldtse added the bug Something isn't working label Mar 28, 2023
@ronaldtse ronaldtse changed the title PDF: "NOTE" label runs into content PDF: "NOTE" and "NOTE X" labels runs into content Mar 28, 2023
@Intelligent2013
Copy link
Contributor

Intelligent2013 commented Mar 29, 2023

I've found the reason of this issue.
3 month ago I've comment the padding-right style for note's name:

		<xsl:if test="$namespace = 'ogc'">
			<xsl:attribute name="font-weight">bold</xsl:attribute>
			<!-- <xsl:attribute name="padding-right">1mm</xsl:attribute> -->
		</xsl:if>

for the added feature render/preprocess-xslt in the metanorma/mn2pdf#169 (and #472).

I've tried to add manually this fragment into the presentation xml:

<render>
		<preprocess-xslt>
			<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
				<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
				<xsl:strip-space elements="*"/>
				<!-- note/name -->
				<xsl:template match="*[local-name() = 'note']/*[local-name() = 'name']">
					<xsl:copy>
						<xsl:apply-templates select="@*|node()"/>
						<xsl:if test="normalize-space() != ''">:<tab/>
						</xsl:if>
					</xsl:copy>
				</xsl:template>
			</xsl:stylesheet>
		</preprocess-xslt>
	</render>

and after that PDF looks correct:
image

image

@opoudjis could you check why preprocess-xslt is missing in the XML?

@opoudjis
Copy link
Contributor

opoudjis commented Mar 30, 2023

@Intelligent2013 All extensions in Metanorma XML are now supposed to go under /{root}/metanorma-extension/..., which has been renamed from misc-container. Have you updated where /render/preprocess-xslt is inserted?

ogc-standard/render/preprocess-xslt sounds like my XML processing would never have been ok with it...

@Intelligent2013
Copy link
Contributor

@opoudjis could you point me to the generated presentation XML with the render element?
I've tried to generate XML for the OGC document https://github.com/metanorma/ogc-muddi-mds/tree/main/sources/mds-guide and don't see the element render.

@opoudjis
Copy link
Contributor

opoudjis commented Apr 1, 2023

I'm not finding either preprocess-xslt or render in my code. Going back to the original issue, #472, I see I was going to add a render element, and I also raised the concern that this was going to take too long, and I had too many other things to do, in #473.

Because I'm completely confused as to the chain of events: @Intelligent2013 you assumed I was already going to insert that test Stylesheet into production code, and I assumed you were going to wait for us to coordinate a production cycle to do so. Right?

If so, I will now have to scramble to put this into production, for OGC only. As I said very very clearly in #473, I DO NOT HAVE THE TIME to roll this out for all flavours, and I do not anticipate ever getting the time to unless this is expressly prioritised.

@opoudjis
Copy link
Contributor

opoudjis commented Apr 1, 2023

I'm going to put this in //metanorma-extension/render/preprocess-xslt : I don't want random bits of extension code scattered throughout the XML, I want them all in one place.

As you can see clearly from metanorma/isodoc#473, this is a huge task, and I am doing the bare minimum to get this one stylesheet fragment working. If you want me working on the full ticket, don't give me 15 urgent tickets and two new flavours to implement. These tasks are prioritised according to available resourcing.

opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 1, 2023
@opoudjis
Copy link
Contributor

opoudjis commented Apr 1, 2023

Implemented generic loader and processor of preprocess-xslt, now to instantiate for OGC...

opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 1, 2023
opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 1, 2023
@opoudjis
Copy link
Contributor

opoudjis commented Apr 1, 2023

Sent sample to @Intelligent2013 to confirm this now works for him.

@Intelligent2013 One concern I do have: for HTML/DOC, the Presentation XML remains distinct from the HTML, and therefore the transform needs to preserve all nodes it does not have a rule for:

<preprocess-xslt>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mn="http://riboseinc.com/isoxml" version="1.0">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
    <xsl:preserve-space elements="*"/>
    <xsl:template match="@* | node()">
      <xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy> <!-- preserve everything -->
    </xsl:template>
    <xsl:template match="mn:note/mn:name">
      <xsl:copy><xsl:apply-templates select="@*|node()"/><xsl:if test="normalize-space() != ''">:<mn:tab/></xsl:if></xsl:copy>
    </xsl:template>
  </xsl:stylesheet>
</preprocess-xslt>

Because you're integrating this into your single pass of XSLT, I take it that I should suppress those lines for anything you run, right? Meaning

<preprocess-xslt format="doc,html">
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mn="http://riboseinc.com/isoxml" version="1.0">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
    <xsl:preserve-space elements="*"/>
    <xsl:template match="@* | node()">
      <xsl:copy><xsl:apply-templates select="@* | node()"/></xsl:copy> <!-- preserve everything -->
    </xsl:template>
    <xsl:template match="mn:note/mn:name">
      <xsl:copy><xsl:apply-templates select="@*|node()"/><xsl:if test="normalize-space() != ''">:<mn:tab/></xsl:if></xsl:copy>
    </xsl:template>
  </xsl:stylesheet>
</preprocess-xslt>
<preprocess-xslt format="pdf">
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mn="http://riboseinc.com/isoxml" version="1.0">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no"/>
    <xsl:preserve-space elements="*"/>
    <xsl:template match="mn:note/mn:name">
      <xsl:copy><xsl:apply-templates select="@*|node()"/><xsl:if test="normalize-space() != ''">:<mn:tab/></xsl:if></xsl:copy>
    </xsl:template>
  </xsl:stylesheet>
</preprocess-xslt>

I'm also hoping that my namespacing in the XSLT means you don't need to manipulate it further.

@opoudjis
Copy link
Contributor

opoudjis commented Apr 1, 2023

A further complication, although this I think means life is easier for you.

The way I've set up the code, all processing of Presentation XML is run through my XSLT pre-processing, before I pass it on to format-specific processing. That means that you don't need to run the preprocess-xslt, because I already do. (I hadn't already realised it, but the XSL:FO parser shares a preprocessor with the HTML and DOC, and that is the preprocessor I have updated.)

This means that you can ignore the preprocess-xslt, because what you are passed from Metanorma has already run it. OTOH, it means that if I pass you the output Presentation XML file, you do have to run it to get the same results.

@Intelligent2013
Copy link
Contributor

Because I'm completely confused as to the chain of events: @Intelligent2013 you assumed I was already going to insert that test Stylesheet into production code, and I assumed you were going to wait for us to coordinate a production cycle to do so. Right?

Yes, I've thought clearly that the XSLT integrated into XML in the production mode, not just proof-of-concept.

Because you're integrating this into your single pass of XSLT, I take it that I should suppress those lines for anything you run, right?

Yes, right. I don't need the identical transformation template (<xsl:template match="@* | node()">).

I'm also hoping that my namespacing in the XSLT means you don't need to manipulate it further.

<preprocess-xslt format="pdf">
  <xsl:stylesheet ... xmlns:mn="http://riboseinc.com/isoxml"...>
    ...
    <xsl:template match="mn:note/mn:name">
      <xsl:copy><xsl:apply-templates select="@*|node()"/><xsl:if test="normalize-space() != ''">:<mn:tab/></xsl:if></xsl:copy>
    </xsl:template>
  </xsl:stylesheet>
</preprocess-xslt>

It means, that I have to replace mn in the @match by *[local-name()=''] and remove mn in the another places.

This means that you can ignore the preprocess-xslt, because what you are passed from Metanorma has already run it. OTOH, it means that if I pass you the output Presentation XML file, you do have to run it to get the same results.

Ok, then I'll close metanorma/mn2pdf#190 and stop working on preprocess issue.

@opoudjis
Copy link
Contributor

opoudjis commented Apr 4, 2023

Except!

You generate the PDF from files written to disk.

java -Xss5m -Xmx2048m -Djava.awt.headless=true -Dapple.awt.UIElement=true -Duser.home=/Users/nickn -jar /Users/nickn/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/mn2pdf-1.66/lib/../bin/mn2pdf.jar --xml-file "/Users/nickn/Documents/Arbeit/upwork/ribose/service-publications-docs/1109-Q.708B/T-SP-Q.708B-2016-E.presentation.xml" --xsl-file "/Users/nickn/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/metanorma-itu-2.2.8/lib/isodoc/itu/itu.service-publication.xsl" --pdf-file "/Users/nickn/Documents/Arbeit/upwork/ribose/service-publications-docs/1109-Q.708B/T-SP-Q.708B-2016-E.pdf" --syntax-highlight --font-manifest "/var/folders/st/02jjnpwd1bz15gp_7m7fm1lr0000gs/T/fontist_locations20230404-86211-pwan62.yml"

This means that I have to write out the Presentation XML file specific to PDF that I generate to disk, and have you process that, as T-SP-Q.708B-2016-E.presentation.pdf.xml, distinct from the original T-SP-Q.708B-2016-E.presentation.xml

@opoudjis
Copy link
Contributor

opoudjis commented Apr 4, 2023

The file you will be parsing in mnconvert will always be written out to /tmp (Tempfile), though only in OGC will it differ in content at the moment from the original Presentation XML.

@Intelligent2013
Copy link
Contributor

@opoudjis just for info, mnconvert parses the presentation XML with semantic layer in this order:

  • the semantic layer is using as base XML for conversion,
  • the presentation layer is using for the clause/table/figure numbers, note/example name, etc., and requirement tables xml.

opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 6, 2023
opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 6, 2023
opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 8, 2023
opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 8, 2023
opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 8, 2023
opoudjis added a commit to metanorma/isodoc that referenced this issue Apr 8, 2023
@Intelligent2013
Copy link
Contributor

@opoudjis I've generated presentation XML and it looks so:

<name>NOTE  1</name>
<p id="_">For translation into XML

It's ok? Should I add tab indent after name as earlier? I don't understand what I need to do...

@Intelligent2013
Copy link
Contributor

Gemfile.lock:

GIT
  remote: https://github.com/metanorma/isodoc
  revision: ecaee55249df19d62d06c6a4f8d987bd66549c84
  branch: main
  specs:
    isodoc (2.5.2)

@Intelligent2013
Copy link
Contributor

PDF generates ok now:

image

image

@opoudjis thank you!

@ronaldtse
Copy link
Contributor Author

Thank you @opoudjis @Intelligent2013 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

3 participants