How to control left margin with programlisting?
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 41
- Joined: Fri Dec 15, 2006 8:09 pm
- Location: Madrid
- Contact:
How to control left margin with programlisting?
Dear members,
I would like to contol the left margin when I use programlisting tag:
so the output is sensible to the indentation I am using when writing document, so the leading blank before the contents of the programlisting are considered. If I do instead:
so I don't indent the contains of the programlisting, then I get the right output, but it is ugly source xml file and the format strategy could modify its possition. Is there any way in order don't consider such leading blank without affecting the format of the document?. I have tried also using: CDATA but I get the same result.
Thanks in advance,
David
I would like to contol the left margin when I use programlisting tag:
Code: Select all
<chapter>
...
<sect1>
....
<programlisting linenumbering="numbered">
private Item orderItem; // NOT: private Item order_item;
</programlisting>
</sect1>
</chapter>
Code: Select all
<chapter>
...
<sect1>
....
<programlisting linenumbering="numbered">
private Item orderItem; // NOT: private Item order_item;
</programlisting>
</sect1>
</chapter>
Thanks in advance,
David
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
The DocBook stylesheets preserve the content of the programlisting element when they generate HTML / PDF / etc. output from your XML document. You can change this only with a DocBook customization layer. Also the programlisting element is included by default in the Preserve space elements list (available in Options -> Preferences -> Editor -> Format -> XML) taken into account by oXygen when the Format and Indent (pretty-print) action is applied. This is why the Format and Indent action does not indent the programlisting element so it looks ugly. If you want to format this element too just remove it from the Preserve space elements list but the exact content of the element after format and indent will appear also in the result of the DocBook transformation.
Regards,
Sorin
The DocBook stylesheets preserve the content of the programlisting element when they generate HTML / PDF / etc. output from your XML document. You can change this only with a DocBook customization layer. Also the programlisting element is included by default in the Preserve space elements list (available in Options -> Preferences -> Editor -> Format -> XML) taken into account by oXygen when the Format and Indent (pretty-print) action is applied. This is why the Format and Indent action does not indent the programlisting element so it looks ugly. If you want to format this element too just remove it from the Preserve space elements list but the exact content of the element after format and indent will appear also in the result of the DocBook transformation.
Regards,
Sorin
-
- Posts: 41
- Joined: Fri Dec 15, 2006 8:09 pm
- Location: Madrid
- Contact:
How to use a local xsl file?
Dear Sorin,
Thanks for your input. I have followed your recomendation and on the presentation is explained how to addapt the generation process using custiom xsl file.
Docbook claims that it doesn't find the docbook.xsl, because it tries to find relative to
the project directory, instead of relative to the plugins directory.
mydocbook.xsl:
so, is there a way to put my adapted xsl file in to a local directory, importing a the docbook.xsl file from oxygen install dir?
I have moved mybook.xsl into oxygen install directory, but now when I start the transformation, I get a fail on line 3 from docbook.xsl. The line 3 is contained on the following line:
so, what is wrong, rigth, now?
Thanks,
David
Thanks for your input. I have followed your recomendation and on the presentation is explained how to addapt the generation process using custiom xsl file.
Docbook claims that it doesn't find the docbook.xsl, because it tries to find relative to
the project directory, instead of relative to the plugins directory.
mydocbook.xsl:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="frameworks/docbook/xsl/fo/docbook.xsl" />
<xsl:param name="paper.type" select="'A4landscape'"/>
<xsl:param name="orientarion" select="'landscape'"></xsl:param>
</xsl:stylesheet>
I have moved mybook.xsl into oxygen install directory, but now when I start the transformation, I get a fail on line 3 from docbook.xsl. The line 3 is contained on the following line:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:ng="http://docbook.org/docbook-ng"
xmlns:db="http://docbook.org/ns/docbook"
exclude-result-prefixes="db ng exsl"
version='1.0'>
Thanks,
David
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: How to use a local xsl file?
Post by sorin_ristache »
You can put your XSL file in any local directory. Just use the correct relative path to the imported docbook.xsl file in the href attribute instead of href="frameworks/docbook/xsl/fo/docbook.xsl".dleal wrote:is there a way to put my adapted xsl file in to a local directory, importing a the docbook.xsl file from oxygen install dir?
This line loooks ok. What is the error message?dleal wrote:when I start the transformation, I get a fail on line 3 from docbook.xsl. The line 3 is contained on the following line
Regards,
Sorin
-
- Posts: 41
- Joined: Fri Dec 15, 2006 8:09 pm
- Location: Madrid
- Contact:
What I did, was to define my mydocbook.xsl like this:
but I have to hard code the absolute addres of my oxygen plugins instalation. My last question was if there is a possibility to indicate that this file reside on the default oxygen instalation, without explicitly writting the whole address. I have tried to use as prefix ${frameworks} but it doesn't work. My mydocbook.xsl file is on my project location.
Now about the original problem (programlisting) I have added the following lines on my
mybook.xsl file:
No I have solved partially my problem, because:
1. The font-size at 75% so I feet more lines.
but, I have to set
in order to avoid a lot of '-'symbols instead of leading blanks (about this problem I have seen another post, but without solution).
Now a long line wrapped has no symbol at the begining and it is not indented. Why?
but my original question about how to avoid the source code is indented I don't know how to solve it. I don't know what kind of parameter I have to set in order to avoid such left margin on my code. I would prefer to configure monospace.verbatim.properties, because I have a master file with a set of childen files, so I have to re-indent every one if I set indentation policy in order to delete leading blanks on Oxygen configuration properties in Eclipse.
Thanks sorin, for your help and interest,
David
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import
href="file:/J:/ECLIPSE/extPlugins/eclipse/plugins/com.oxygenxml.editor_7.0.0/frameworks/docbook/xsl/fo/docbook.xsl"/>
<!-- ... -->
</xsl:stylesheet>
Now about the original problem (programlisting) I have added the following lines on my
mybook.xsl file:
Code: Select all
<xsl:attribute-set name="monospace.verbatim.properties" use-attribute-sets="verbatim.properties
monospace.properties">
<xsl:attribute name="font-size">75%</xsl:attribute>
<xsl:attribute name="wrap-option">wrap</xsl:attribute>
<xsl:attribute name="hyphenation-character">►</xsl:attribute>
</xsl:attribute-set>
1. The font-size at 75% so I feet more lines.
but, I have to set
Code: Select all
<xsl:param name="hyphenate.verbatim">0</xsl:param>
Now a long line wrapped has no symbol at the begining and it is not indented. Why?
but my original question about how to avoid the source code is indented I don't know how to solve it. I don't know what kind of parameter I have to set in order to avoid such left margin on my code. I would prefer to configure monospace.verbatim.properties, because I have a master file with a set of childen files, so I have to re-indent every one if I set indentation policy in order to delete leading blanks on Oxygen configuration properties in Eclipse.
Thanks sorin, for your help and interest,
David
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
You have the following two options:dleal wrote:My last question was if there is a possibility to indicate that this file reside on the default oxygen instalation, without explicitly writting the whole address.
- use a relative path instead of the full path, for example if mydocbook.xsl is located in J:/ECLIPSE/extPlugins/eclipse/workspace/project use the path ../plugins/com.oxygenxml.editor_7.0.0/frameworks/docbook/xsl/fo/docbook.xsl
- use an XML catalog to resolve the location specified in the stylesheet, which can be any URI, to the location of the fo/docbook.xsl that comes with the oXygen plugin. You can see an example catalog in J:/ECLIPSE/extPlugins/eclipse/plugins/com.oxygenxml.editor_7.0.0/frameworks/docbook/catalog.xml.
If you prefer a different wrap style for verbatim elements like programlisting you should customize the DocBook FO stylesheet or wrap the content of programlisting yourself in the XML source document before the transformation. Also you can set the character used to mark the end of line in the wrapped lines, for example a small arrow like the one on the Enter key. Look at the monospace.verbatim.properties attribute set, the hyphenation-character attribute. Make sure the character you set in this attribute is included in the font used for the output text and also set the hyphenate.verbatim parameter to 1.dleal wrote:Now a long line wrapped has no symbol at the begining and it is not indented. Why?
dleal wrote:but my original question about how to avoid the source code is indented I don't know how to solve it. I don't know what kind of parameter I have to set in order to avoid such left margin on my code.
As I said before the indentation of verbatim elements is preserved in the output and to change this you have to create a DocBook customization layer. The indentation that you have in the XML source will also be in the output of the transformation. This means you cannot avoid an ugly source XML file. No, the format strategy applied by the Format and Indent action does not change this indentation because as I said already programlisting is a member of the Preserve space elements list set in Options -> Preferences -> Editor -> Format -> XML.dleal wrote:so I don't indent the contains of the programlisting, then I get the right output, but it is ugly source xml file and the format strategy could modify its possition.
Regards,
Sorin
-
- Posts: 41
- Joined: Fri Dec 15, 2006 8:09 pm
- Location: Madrid
- Contact:
Dear Sorin,
Thanks again for your hints.
About catalogue solution:
Now I have the file:
on my home directory, I have added this catalog.xml file on the Oxygen Catalog configuration on Eclipse, and I want to use it like this:
but id doesn't work, I don't know if I can use the catalog information as root directory.
2. About indentation on programlisting ( or monospace.verbatim.properties):
so I have to redefine the programlisting, I don't know to do that in order to get such effect. I am suprissed that this problem no one else solved before than me.
Thanks Soring,
David
Thanks again for your hints.
About catalogue solution:
Now I have the file:
Code: Select all
<?xml version="1.0"?>
<rewriteSystem
systemIdStartString="file:/J:/ECLIPSE/extPlugins/eclipse/plugins/com.oxygenxml.editor_7.0.0"
rewritePrefix="oxygen_dir"/>
</catalog>
Code: Select all
<xsl:import
href="oxygen_dir/frameworks/docbook/xsl/fo/docbook.xsl"/>
2. About indentation on programlisting ( or monospace.verbatim.properties):
so I have to redefine the programlisting, I don't know to do that in order to get such effect. I am suprissed that this problem no one else solved before than me.
Thanks Soring,
David
-
- Posts: 41
- Joined: Fri Dec 15, 2006 8:09 pm
- Location: Madrid
- Contact:
About left indent problem:
I have tried to set the property linefeed-treatment property to preserve and to no-preserve, but I get the same output.
About the hyphen symbol:
How do I know that my symbol ► is supported?, where can I find supported symbols for PDF fonts?
About the catalog problem:
Now I have modified the catalog.xml into:
but I am not sure about the systemStartString, no I use it like this:
but I get fail on reading the file:
on Catalogue preference I have:
Prefer market to System (any way I have tried to set it tu public)
Thanks in advance,
David
Code: Select all
<xsl:attribute-set name="monospace.verbatim.properties" use-attribute-sets="verbatim.properties
monospace.properties">
<xsl:attribute name="text-align">start</xsl:attribute>
<xsl:attribute name="font-size">75%</xsl:attribute>
<xsl:attribute name="wrap-option">wrap</xsl:attribute>
<xsl:attribute name="hyphenation-character">►</xsl:attribute>
<xsl:attribute name="linefeed-treatment">preserve</xsl:attribute>
</xsl:attribute-set>
About the hyphen symbol:
How do I know that my symbol ► is supported?, where can I find supported symbols for PDF fonts?
About the catalog problem:
Now I have modified the catalog.xml into:
Code: Select all
<?xml version="1.0"?>
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook"
rewritePrefix="file:/J:/ECLIPSE/extPlugins/eclipse/plugins/com.oxygenxml.editor_7.0.0/frameworks/docbook"/>
</catalog>
Code: Select all
<xsl:import
href="http://www.oasis-open.org/docbook/xsl/fo/docbook.xsl"/>
Code: Select all
http://www.oasis-open.org/docbook/xsl/fo/docbook.xsl
Prefer market to System (any way I have tried to set it tu public)
Thanks in advance,
David
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
You have to check that the symbol is included in the font used for the body of the PDF document. Usually there are different fonts for titles and body in a PDF document generated from a DocBook XML one. The default font used for body in a PDF generated with Apache FOP is Times New Roman. If the default font does not include the characters that you need to display in the output you can change it with the body.font.family parameter. Also you have to set the new font for Apache FOP using the FOP configuration file. See the article about setting up a font for Apache FOP in oXygen available on the Documentation page.dleal wrote:About the hyphen symbol:
How do I know that my symbol ► is supported?, where can I find supported symbols for PDF fonts?
This XML catalog is correct for entity references (for example DOCTYPE declarations), not for URI references. In your case you want to resolve a reference to docbook.xsl used in an XSLT stylesheet and for this you need:dleal wrote:About the catalog problem:
Now I have modified the catalog.xml into:but I am not sure about the systemStartStringCode: Select all
<?xml version="1.0"?>
<rewriteSystem
systemIdStartString="http://www.oasis-open.org/docbook"
rewritePrefix="file:/J:/ECLIPSE/extPlugins/eclipse/plugins/com.oxygenxml.editor_7.0.0/frameworks/docbook"/>
</catalog>
Code: Select all
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="http://www.oasis-open.org/docbook"
rewritePrefix="file:/J:/ECLIPSE/extPlugins/eclipse/plugins/com.oxygenxml.editor_7.0.0/frameworks/docbook"/>
</catalog>
Use the XML catalog that I posted and reopen the Eclipse editor with the file containing the declaration that needs to be resolved through the catalog, that is the XSLT stylesheet with the xsl:import declaration. In the XML Catalog page from Preferences you can read this with bold print under the XML Catalogs list.dleal wrote:but I get fail on reading the file:Code: Select all
<xsl:import
href="http://www.oasis-open.org/docbook/xsl/fo/docbook.xsl"/>
on Catalogue preference I have:Code: Select all
http://www.oasis-open.org/docbook/xsl/fo/docbook.xsl
Prefer market to System (any way I have tried to set it tu public)
Regards,
Sorin
-
- Posts: 41
- Joined: Fri Dec 15, 2006 8:09 pm
- Location: Madrid
- Contact:
Dear Sorin,
Thanks again for your hints and interest.
About the catalogue problem
I did what you said, so I have on my %USERPROFILE% dir a catalog.xml file with the contents you said. On XML Oxygen Catalog configuration I have:
Use default catalog (selected)
On XML Catalogs there is my: %USERPROFILE%/catalog.xml
and on Prefer I have selected public
Now on my mydocbook.xsl I have:
and I get a Eclipse warning informing that failed loading this file.
so, it doesn't reconize well this alias, I guess.
Please let me know any hint about this,
Thanks,
David
Thanks again for your hints and interest.
About the catalogue problem
I did what you said, so I have on my %USERPROFILE% dir a catalog.xml file with the contents you said. On XML Oxygen Catalog configuration I have:
Use default catalog (selected)
On XML Catalogs there is my: %USERPROFILE%/catalog.xml
and on Prefer I have selected public
Now on my mydocbook.xsl I have:
Code: Select all
<xsl:import href="http://www.oasis-open.org/docbook/xsl/fo/docbook.xsl"/>
Code: Select all
Failure reading: http://www.oasis-open.org/docbook/xsl/fo/docbook.xsl
Please let me know any hint about this,
Thanks,
David
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
Hello,
Can you post here the XML catalog, the location of docbook.xsl on disk and the beginning of the XSLT stylesheet containing the import declaration for docbook.xsl?
Regards,
Sorin
Can you post here the XML catalog, the location of docbook.xsl on disk and the beginning of the XSLT stylesheet containing the import declaration for docbook.xsl?
Regards,
Sorin
-
- Posts: 41
- Joined: Fri Dec 15, 2006 8:09 pm
- Location: Madrid
- Contact:
I have found the problem
Dear Sorin,
I have found the problem, the reason is that I use virtual units, that is the MS-DOS command: subst. I use them for creating working virtual units and to avoid of writing long path on my working files, so my J:\ units represents:
and P:\ unit represent:
If I use on catalog.xml non virtual units it works, I don't know why, but in general the virtual units works well on every situations, but for this case it doesn't:
Thanks for your interest,
David
I have found the problem, the reason is that I use virtual units, that is the MS-DOS command: subst. I use them for creating working virtual units and to avoid of writing long path on my working files, so my J:\ units represents:
Code: Select all
C:\Archivos de programa\Java
Code: Select all
C:\Documents and Settings\David Leal Valmaña\Mis documentos\Projects
Code: Select all
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="http://www.oasis-open.org/docbook"
rewritePrefix="file:/C:/Archivos de programa/Java/ECLIPSE/extPlugins/eclipse/plugins/com.oxygenxml.editor_7.0.0/frameworks/docbook"/>
</catalog>
David
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service