Using document as a template: problem with heading numbering - templates

The document body is hardcoded and then inserted into a template document with contains cover, summary, headers and styles. Heading styles are numbered 1, 1.1, 1.2, and so on. But to insert a heading just with 'Heading [n]' style does not work, numbering is lost. I think this happens because numbering is set through a multilevel list with headings attached.
Question: is it possible to use a document as a template without coding any formatting, or it is inevitable to deal with list styles in the code?

Yes, you can use a document as a template without any formatting. Please note that when you copy nodes from one document to another, this option specifies how formatting is resolved when both documents have a style with the same name, but different formatting.
The formatting is resolved as follows:
Built-in styles are matched using their locale independent style
identifier. User defined styles are matched using case-sensitive
style name.
If a matching style is not found in the destination document, the
style (and all styles referenced by it) are copied into the
destination document and the imported nodes are updated to reference
the new style.
If a matching style already exists in the destination document, what
happens depends on the importFormatMode parameter passed to
Document.ImportNode as described below.
When using the UseDestinationStyles option, if a matching style already exists in the destination document, the style is not copied and the imported nodes are updated to reference the existing style.
So, in your case, I suggest you please use UseDestinationStyles option while inserting one document into another.
I work with Aspose as Developer Evangelist.

Related

Changing citation style to number-letter in papaja Rmarkdown package

I'm writing a scientific manuscript in RMarkdown using the papaja package, which enables me to report my statistics beautifully. However, the journal now requires me to submit a Word document with number-letter referencing. Is it possible to change the referencing style to a number-letter style in Papaja?
I tried opening the LaTeX output from papaja, but it has the citations set out in the text in APA format (e.g. "Apthorp, Bolbecker, Bartolomeo, O'Donnell, \& Hetrick, 2018"), which is not useful to me.
Here's the code from the top of the manuscript:
bibliography : ["PD_sway-1.bib"]
floatsintext : no
figurelist : no
tablelist : no
footnotelist : no
linenumbers : yes
mask : no
draft : no
documentclass : "apa6"
classoption : "man"
output : papaja::apa6_pdf
It would be great if I could get a Word document with number-letter referencing that I could then edit, but a LaTeX file or PDF with the correct citation format would be fine too.
The references are already typed out in APA style in the LaTeX document because they are handled by pandoc-citeproc rather than LaTeX. This has the advantage that the automatic reference formatting also works when you output your document in Word format. To get a Word document all you need to do is change the output line in the YAML front matter:
output: papaja::apa6_docx
Note that the formatting of Word documents that pandoc supports is somewhat limited and you may have to fix some things manually. From the corresponding section in the papaja manual:
More over, rendered documents in DOCX format require some manual work before they fully comply with APA guidelines.
We, therefore, provide the following checklist of necessary changes:
Always,
add a header line with running head and page number
If necessary,
position author note at the bottom of page 1
move figures and tables to the end of the manuscript
add colon to level 3-headings
in figure captions,
add a colon following the figure numbers and italicize(e.g. "Figure 1. This is a caption.")
in tables,
add horizontal rules above the first and below the last row
add midrules
Changing the citation style works just as it does in any R Markdown document. The work-in-progress papaja manual has a section on this:
Other styles can be set in the YAML front matter by specifying a CSL, or Citations Style Language, file. You can use either one of the large number of existing CSL files, customize an existing CSL file, or create a new one entirely.
To change the citation style, download the CSL file and add the following to the YAML front matter:
csl: "path/to/mystyle.csl"
I'm not sure what style the journal requires but most likely a corresponding CSL file already exists.

Extract a portion of a docx into a new docx

I have a docx file with just text. I would like to create a new docx file containing just part of a page in the original docx. I am using python-docx for this.
So far I have been able to transverse the original docx document and copy each desired paragraph/run in the original to the new document as follows (this example should make an exact copy, I believe):
Doc = docx.Document('/tmp/input.docx')
OutDoc = docx.Document()
for para in Doc.paragraphs:
currentParagraph = OutDoc.add_paragraph(style=para.style)
for run in para.runs:
currentParagraph.add_run(run.text, style=run.style)
OutDoc.save('/tmp/output.docx')
Even though I am copying all style information, it seems that I am missing something, as the output lacks some of the formatting.
In Word, the style name applied to a paragraph or run (or any other content) is ignored if that style is not explicitly defined in the new document.
You can either parse through the styles in the source document and recreate each one in the new document, or create a blank "template" document for the new document that already contains the styles you want.
The "default" python-docx document template includes many of the built-in styles, but if your document uses any customized styles, that would explain the symptom you're seeing.
See these pages in the documentation for more:
http://python-docx.readthedocs.org/en/latest/user/styles-understanding.html
http://python-docx.readthedocs.org/en/latest/user/styles-using.html
http://python-docx.readthedocs.org/en/latest/api/document.html#docx.document.Document.styles
http://python-docx.readthedocs.org/en/latest/api/style.html

Why is Visible controlled by

In my home page I have the following snippet that fetches all blog posts:
var docs = CurrentPage.Children.Where("Visible")
What I don't understand is that Visible is controlled by a property in the document named umbracoNaviHide. Setting it to true on the document excludes the page from the list above.
How is umbracoNaviHide translated to Visible? I have no macros or XSLT (none actually) that is doing anything funny...
umbracoNaviHide is one of umbraco's internal property implementations.
We used to have to check the property explicitly in xslt but nowadays it is used as you are using it here.
Here is a more complete explanation from the Umbraco wiki
The "umbracoNaviHide" is an Umbraco convention for marking nodes which
should not show up in a navigational context. It is normally added (or
inherited) on every Document Type with a Data Type of "True/false".
NOTE: This property is not added by default on new installations,
meaning you need to add it manually
There are a number of other useful properties that everybody should know about:
umbracoSitemapHide
umbracoUrlAlias
umbracoUrlName
umbracoInternalRedirectId
umbracoRedirect
We always insert these properties on a master page doctype so that all other doc types that represent data on web page content nodes inherit them
Wing

How do I display a field name containing the substring OMIT in ApEx?

One of the fields in my database table is named DATEOFDISCHARGEFROMITU. In any report output, this displays as DATEOFDISCHARGEFRU. I've figured out that the missing characters form the word 'OMIT', which makes me think it's related to this old problem in a previous version of ApEx (I'm using version 4.1.)
Is there a way to display the whole field name in the report header when the field name contains the string 'OMIT'?
Note: Using html character codes will allow the field name to display properly, but then when the report is exported to CSV the character codes are of course shown instead of the full field name. I need a solution that works for exports as well as displaying onscreen.
Platforms (tested): Oracle Application Express (APEX), Version 4.0.2
Note: I am not sure how the linked OTN post is relevant to your problem aside from the coincidence that their file export contains the word "OMIT" and your column title contains the word "OMIT".
It's safe to say that "OMIT" isn't an APEX or ORACLE reserved word that is sabotaging your output. However, if you were talking about a scrap of SQL that attempted to create a table named "SELECT" or "WHERE"
i.e., SELECT * FROM "SELECT" WHERE...
you'll be blocked by the RDBMS from proceeding. :)
I tried an export with a query that contained a column header labeled "OMIT" (see the far right in the example.) The .csv file interpreted by Microsoft Excel looked like this:
I wrote up a separate Q&A post about creating dynamic APEX report headers to answer your follow-on question about a suitable solution for providing a clean, htmlcode-free output when a report is eventually exported to a text, comma separated (or other delimited) output.
In summary, the linked post suggests to set up a dynamic PL/SQL Function within a page item. The page item can be referenced directly in the report column header definition. This is a screenshot demonstrating a possible solution:
The link to the general explanation has more details on the APEX design tasks that gets to this final product.
Onward.
I solved this by using this solution for exporting to csv without an enclosing quote character - as that was another challenge I was faced with for the particular application I was developing. By manually creating the export file I was also able to define the column headings exactly, and the "OMIT" issue did not occur.
Technically that's not a solution for displaying a report with the required headings that can also be exported (Richard's response does that) but it does what I need it to and solves the immediate problem of the DATEOFDISCHARGEFROMITU column heading.

How to deal with presence or not of xml namespaces using xslt

I have some XML/TEI documents, and i'm writing an XSLT 2.0 to extract their content.
Almost all TEI documents has no namespace, but one has the default namespace (xmlns="http://www.tei-c.org/ns/1.0").
So all documents has the same aspect, with unqulified tags like <TEI> or <teiHeader>, but if I try to extract the content, all works with "non-namespaced-documents", but nothing (of course) is extracted from the namespaced-document.
So i used the attribute xpath-default-namespace="http://www.tei-c.org/ns/1.0" and now (of course) the only document working is the namespaced one.
I can't edit documents at all, so what I'm asking is if there's a way to change dynamically the xpath-default-namespace in order to make work xpaths like //teiHeader both with namespaced and non-namespaced documents
If you are using XSLT 2.0, then you do have the option for a wildcard match for the namespace in a node test.
e.g. //*:teiHeader
http://www.w3.org/TR/xpath20/#node-tests
A node test can also have the form
*:NCName. In this case, the node test is true for any node of the principal
node kind of the step axis whose local
name matches the given NCName,
regardless of its namespace or lack of
a namespace.
This is functionally equivalent to Dimitre Novatchev's example, but a little shorter/easier to type.
However, this will only work in XSLT/XPATH 2.0.
There isn't really a clean way to do precisely what you are asking. However, there are workarounds available. You could use a two stage process whereby you strip the namespace from the document if it's present and then pass it through the same templates for all content.
There is a good example (in XSLT 1) of doing this in the DocBook XSLT. Take a look at html/docbook.xsl and common/stripns.xsl
Basically, you would need to assign the result of stripping the namespace to a variable and then call your existing templates (for the non namespaced) content but select the variable.
It is ugly, but this gives you what you want:
//*[name()='teiHeader']
If you use this style for all location steps in any XPath expression, the XPath expressions will select elements only by name, regardless whether or not the elements belong to any namespace.