Arbitrary elements in Prolog
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 6
- Joined: Mon Jan 03, 2022 5:54 pm
Arbitrary elements in Prolog
Post by sweetsweetstefan »
Hi there! I am using Oxygen XML Author v24 to output articles in Markdown (GitHub flavoured). So far everything is great, except for one requirement: I need a YAML header at the top of my articles with some metadata. Here is what I need:
I've experimented with the Prolog element, and the Author element renders in the same general way that I need, but my publishing software needs the two keys I mention above, title and slug. I tried adding Othermeta and Data elements, but unlike the Author element, the transformation does not render Othermeta and Data elements to Markdown. I also tried adding a new DITA element to my metaDecl.mod file, but I wasn't able to get it to work.
Before trying with the Prolog element, I tried modifying the dita2markdownImpl.xsl file and adding a new template that generates what I need, but it started to get too complicated.
Does anyone have any ideas on how I might be able to get this to work? Thanks for any help!
Code: Select all
---
title: "Human-readable title"
slug: title-for-location-bar
---
Before trying with the Prolog element, I tried modifying the dita2markdownImpl.xsl file and adding a new template that generates what I need, but it started to get too complicated.
Does anyone have any ideas on how I might be able to get this to work? Thanks for any help!
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Arbitrary elements in Prolog
Hi,
You probably need to make indeed changes in the XSLTs used to generate the Markdown content, for example in OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT3.x/plugins/org.lwdita/xsl/dita2markdown.xsl make these changes to the template which generates the entire file:
Regards,
Radu
You probably need to make indeed changes in the XSLTs used to generate the Markdown content, for example in OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT3.x/plugins/org.lwdita/xsl/dita2markdown.xsl make these changes to the template which generates the entire file:
Code: Select all
<xsl:template match="/">
<xsl:variable name="ast" as="node()">
<xsl:apply-templates/>
</xsl:variable>
<xsl:variable name="ast-flat" as="node()">
<xsl:apply-templates select="$ast" mode="flatten"/>
</xsl:variable>
<xsl:variable name="ast-clean" as="node()">
<xsl:apply-templates select="$ast-flat" mode="ast-clean"/>
</xsl:variable>
---
title: "<xsl:value-of select="($ast-clean/header)[1]"/>"
slug: title-for-location-bar
---
<xsl:apply-templates select="$ast-clean" mode="ast"/>
</xsl:template>
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 6
- Joined: Mon Jan 03, 2022 5:54 pm
Re: Arbitrary elements in Prolog
Post by sweetsweetstefan »
Hi Radu,
Thank you for the suggestion! I agree, I think that's where it has to be inserted. I'll experiment and we'll see what happens!
Regards,
Stefan
Thank you for the suggestion! I agree, I think that's where it has to be inserted. I'll experiment and we'll see what happens!
Regards,
Stefan
-
- Posts: 24
- Joined: Tue Jun 14, 2022 1:08 pm
Re: Arbitrary elements in Prolog
Hello *,
we also try to do a markdown output with metadata in a YAML section at the top of each file.
Using <xsl:value-of select="($ast-clean/header)[1]"/> or similar paths like ($ast-clean/prolog/metadata/othermeta)[1] does not fill in any YAML values in my outputs. Is there maybe a description of this AST so that we know what path to use?
Kind regards
Nicole
we also try to do a markdown output with metadata in a YAML section at the top of each file.
Using <xsl:value-of select="($ast-clean/header)[1]"/> or similar paths like ($ast-clean/prolog/metadata/othermeta)[1] does not fill in any YAML values in my outputs. Is there maybe a description of this AST so that we know what path to use?
Kind regards
Nicole
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Arbitrary elements in Prolog
Hi Nicole,
In the XSLT stylesheet you can output an xsl:message, something like this:
and the message should be visible after publishing in the DITA OT console tab view. In the Oxygen Preferences->"DITA / Logging" page you can set "Show console output->Always" to always show the DITA OT console view while publishing.
Regards,
Radu
In the XSLT stylesheet you can output an xsl:message, something like this:
Code: Select all
<xsl:message><xsl:copy-of select="$ast-clean/"/></xsl:message>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 24
- Joined: Tue Jun 14, 2022 1:08 pm
Re: Arbitrary elements in Prolog
Good morning,
that helped. With the log I found out that, at the point where the dita2markdown.xsl is being evalueted, DITA-OT already stripped <othermeta> contents from the topics. There is no DITA-OT paramater to preserve all <metadata> or <data> either. Does someone know if there are plans on adding this in the future?
A workaround would be that I create HTML output in parallel and write a batch program to merge the metadata into the MD-files. But that seems a bit overkill to me.
If someone knows a different approach, please let us know here.
Kind regards
Nicole
that helped. With the log I found out that, at the point where the dita2markdown.xsl is being evalueted, DITA-OT already stripped <othermeta> contents from the topics. There is no DITA-OT paramater to preserve all <metadata> or <data> either. Does someone know if there are plans on adding this in the future?
A workaround would be that I create HTML output in parallel and write a batch program to merge the metadata into the MD-files. But that seems a bit overkill to me.
If someone knows a different approach, please let us know here.
Kind regards
Nicole
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Arbitrary elements in Prolog
Hi Nicole,
Let's try to take a small example, for example this topic:
referenced in a small DITA Map and then the DITA Map published to Markdown.
In the "DITA-OT3.x/plugins/org.lwdita/xsl/dita2markdown.xsl" stylesheet I added an xsl:message:
I run the publishing and in the DITA OT console view I see at some point:
So the metatadata content inside the topic seems to be preserved and is present when the stylesheet is applied.
Regards,
Radu
Let's try to take a small example, for example this topic:
Code: Select all
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
<topic id="introduction">
<title>Introduction</title>
<prolog>
<metadata>
<othermeta name="some" content="value"/>
</metadata>
</prolog>
<body>
</body>
</topic>
In the "DITA-OT3.x/plugins/org.lwdita/xsl/dita2markdown.xsl" stylesheet I added an xsl:message:
Code: Select all
<xsl:template match="/">
<xsl:message>I AM <xsl:copy-of select="."/></xsl:message>
Code: Select all
[xslt] <othermeta class="- topic/othermeta "
[xslt] content="value"
[xslt] name="some"
[xslt] xtrc="othermeta:1;7:47"
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9434
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Arbitrary elements in Prolog
Hi,
Indeed it seems in the XSLT stylesheet "plugins/org.lwdita/xsl/ast2markdown.xsl" there is this template:
in the mode "ast-clean", used when the $ast-clean variable is being computed which ignores most of the DITA elements from the original document.
Regards,
Radup
Indeed it seems in the XSLT stylesheet "plugins/org.lwdita/xsl/ast2markdown.xsl" there is this template:
Code: Select all
<xsl:template match="@* | node()"
mode="ast-clean" priority="-10">
Regards,
Radup
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
Return to “DITA (Editing and Publishing DITA Content)”
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