Editing rel-links for HTML output
Questions about XML that are not covered by the other forums should go here.
-
- Posts: 58
- Joined: Fri Sep 12, 2008 12:12 am
Editing rel-links for HTML output
Hello all,
In customizing our single page HTML output in DITA we wanted to remove the child links from being under each topic head that had child nodes and all the links that point back to the top, so we changed "NOPARENTLINK" to yes (on line 17) in rel-links.xsl and commented out the "ul-child-links" template call. However now we would like to consider a hybrid format where you can have parent links (links back to the top) but only after each major section (at the bottom of the root node topics only, after all of its children). Is there a way to do this in the rel-links.xsl file?
Also I have a few other curiosities about the rel-links.xsl file while I'm asking about it. For the matching in the templates, such as at the top of the ul-child-links template, what is the expression "descendant::*[contains(@class, ' topic/link ')]" actually matching? Where does the "/link" part come from as a child of a topic? Is this something inserted by the rel-links xsl somewhere else in the transformation? Also why is it that the ul-child-links section specifically that makes the links disappear from under the topic headings rather than the "ol-links", "reference-links", or other templates? Looking at the code I'm trying to get the overall picture of what it is doing, but I'm getting mired in the details.
Finally, for the "NOPARENTLINK" check, what do the conditions here actually check? (I will place hash marks in front of the lines in question):
Of particular interest to me is the @href attribute it tries to match, where does that come from?
Ultimately all I want to do it put a link at the bottom of each major section back to the top, but I'd like to understand some more of rel-links inner workings as well. Sorry to throw so much out there at once. I hope this is digestable.
Thanks,
Josh
In customizing our single page HTML output in DITA we wanted to remove the child links from being under each topic head that had child nodes and all the links that point back to the top, so we changed "NOPARENTLINK" to yes (on line 17) in rel-links.xsl and commented out the "ul-child-links" template call. However now we would like to consider a hybrid format where you can have parent links (links back to the top) but only after each major section (at the bottom of the root node topics only, after all of its children). Is there a way to do this in the rel-links.xsl file?
Also I have a few other curiosities about the rel-links.xsl file while I'm asking about it. For the matching in the templates, such as at the top of the ul-child-links template, what is the expression "descendant::*[contains(@class, ' topic/link ')]" actually matching? Where does the "/link" part come from as a child of a topic? Is this something inserted by the rel-links xsl somewhere else in the transformation? Also why is it that the ul-child-links section specifically that makes the links disappear from under the topic headings rather than the "ol-links", "reference-links", or other templates? Looking at the code I'm trying to get the overall picture of what it is doing, but I'm getting mired in the details.
Finally, for the "NOPARENTLINK" check, what do the conditions here actually check? (I will place hash marks in front of the lines in question):
Code: Select all
<xsl:if test="$NOPARENTLINK='no'">
<xsl:choose>
### <xsl:when test="*[@href][@role='parent']">
### <xsl:for-each select="*[@href][@role='parent']">
<div class="parentlink"><xsl:apply-templates select="."/></div><xsl:value-of select="$newline"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
### <xsl:for-each select="*[@href][@role='ancestor'][last()]">
<div class="parentlink"><xsl:call-template name="parentlink"/></div><xsl:value-of select="$newline"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
Ultimately all I want to do it put a link at the bottom of each major section back to the top, but I'd like to understand some more of rel-links inner workings as well. Sorry to throw so much out there at once. I hope this is digestable.
Thanks,
Josh
-
- Posts: 9439
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Editing rel-links for HTML output
Hi Josh,
I'll try to explain to you some of the XPaths.
descendant::*[contains(@class, ' topic/link ')] means any descendent of the current context node which has a class attribute with the value topic/link . So topic/link is actually the value of the searched attribute. In DITA the value does not actually need to be in the XML file as it is inherited by default from the DTD's for link elements.
<xsl:when test="*[@href][@role='parent']"> means when there is at least one node with the href attribute present and which also has an attribute role with value parent
<xsl:for-each select="*[@href][@role='parent']"> means for each of the nodes as explained above.
<xsl:for-each select="*[@href][@role='ancestor'][last()]"> means the last of the nodes which have a href attribute present and have a role attribute with value ancestor. So the for-each is used in this case to change the context node to the node specified in the xpath so that the call-template will execute the called template on the given context node.
My advice for you is to add an
right in the so that you understand better on which XML node the xsl:if will be applied.
You should find the message in the Oxygen console.
Hope this helps,
Regards,
Radu
I'll try to explain to you some of the XPaths.
descendant::*[contains(@class, ' topic/link ')] means any descendent of the current context node which has a class attribute with the value topic/link . So topic/link is actually the value of the searched attribute. In DITA the value does not actually need to be in the XML file as it is inherited by default from the DTD's for link elements.
<xsl:when test="*[@href][@role='parent']"> means when there is at least one node with the href attribute present and which also has an attribute role with value parent
<xsl:for-each select="*[@href][@role='parent']"> means for each of the nodes as explained above.
<xsl:for-each select="*[@href][@role='ancestor'][last()]"> means the last of the nodes which have a href attribute present and have a role attribute with value ancestor. So the for-each is used in this case to change the context node to the node specified in the xpath so that the call-template will execute the called template on the given context node.
My advice for you is to add an
Code: Select all
<xsl:message>
#############################
<xsl:copy-of select="."/>
</xsl:message>
Code: Select all
<xsl:if test="$NOPARENTLINK='no'">
You should find the message in the Oxygen console.
Hope this helps,
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 58
- Joined: Fri Sep 12, 2008 12:12 am
Re: Editing rel-links for HTML output
Hi Radu,
Thanks for answering some of my questions.
And I do indeed see the hash marks, but not the @@@ signs. It seems like the last() function though would be the most useful for what I am trying to do, because below the last child (of the root parent topic) I want it to have a link back up to that parent. Any idea why I am not seeing the @@@ signs? Did I put the message in the wrong place?
Also one last thing, in the code <div class="parentlink"><xsl:apply-templates select="."/> what templates is it actually applying, since it does not explicitly state the template names? Does it implicitly point to some templates associated with the "parentlink" class, since it is inside of <div> tags?
Thanks,
Josh
Thanks for answering some of my questions.
Ok so does every topic intrinsically have a link class attribute in it, or is it assigned by something?Radu wrote:Hi Josh,
I'll try to explain to you some of the XPaths.
descendant::*[contains(@class, ' topic/link ')] means any descendent of the current context node which has a class attribute with the value topic/link . So topic/link is actually the value of the searched attribute. In DITA the value does not actually need to be in the XML file as it is inherited by default from the DTD's for link elements.
Ok so I did this:<xsl:when test="*[@href][@role='parent']"> means when there is at least one node with the href attribute present and which also has an attribute role with value parent
<xsl:for-each select="*[@href][@role='parent']"> means for each of the nodes as explained above.
<xsl:for-each select="*[@href][@role='ancestor'][last()]"> means the last of the nodes which have a href attribute present and have a role attribute with value ancestor. So the for-each is used in this case to change the context node to the node specified in the xpath so that the call-template will execute the called template on the given context node.
Code: Select all
<xsl:if test="$NOPARENTLINK='no'">
<xsl:choose>
<xsl:when test="*[@href][@role='parent']">
<xsl:message>
#############################
<xsl:copy-of select="."/>
</xsl:message>
<xsl:for-each select="*[@href][@role='parent']">
<div class="parentlink"><xsl:apply-templates select="."/></div><xsl:value-of select="$newline"/>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="*[@href][@role='ancestor'][last()]">
<xsl:message>
@@@@@@@@@@@@@@@@@
<xsl:copy-of select="."/>
</xsl:message>
<div class="parentlink"><xsl:call-template name="parentlink"/></div><xsl:value-of select="$newline"/>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
Also one last thing, in the code <div class="parentlink"><xsl:apply-templates select="."/> what templates is it actually applying, since it does not explicitly state the template names? Does it implicitly point to some templates associated with the "parentlink" class, since it is inside of <div> tags?
Thanks,
Josh
-
- Posts: 1
- Joined: Sat Mar 07, 2009 10:29 am
Re: Editing rel-links for HTML output
How to display html output on the same page? I'm using document.write but it loads output on a different page? Hi basically on top of my page there is a button. When I press the button, I want the result to display at the bottom half of the screen. I'm currently using document.write but that goes to a new page. I know this may seem like a simple question but I'm just drawing a blank. Thank you.
-
- Posts: 9439
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Editing rel-links for HTML output
As an answer to the post by kayanat:
Your answer does not seem to be related to this post or to XML in general.
Please try a JavaScript tutorial http://www.w3schools.com/JS/default.asp
Regards,
Radu
Your answer does not seem to be related to this post or to XML in general.
Please try a JavaScript tutorial http://www.w3schools.com/JS/default.asp
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 9439
- Joined: Fri Jul 09, 2004 5:18 pm
Re: Editing rel-links for HTML output
For Josh:
That attribute is not specified in the XML file but comes as a default value from the topic's DTD. All the DITA OT stylesheets have templates matching these class attribute values instead of the actual element names. In this way you can make specializations and have your own tag name for p and still the output would render it as a paragraph if the class attribute has the same value.
In the same way the DITA link element has a default class attribute of - topic/link .
If you know DTD you can find some of the default class values assignments here:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/dtd/dita132/topic_class.ent
About the xsl:messages:
The #### message is in an xsl:when and the @@@@ is in the xsl:otherwise so of course only one message appears, depending on the decision which is taken in the xsl:when test="*[@href][@role='parent']". In your case the expression probably evaluates to true so the xsl:when body is executed.
About the <div class="parentlink"><xsl:apply-templates select="."/>. The xsl:apply-templates executes all templates matching the current context node. See more details here:http://www.w3schools.com/XSL/el_apply-templates.asp
My advice to you:
The stylesheet which gets applied first on the processed XML input is probably dita2htmlImpl.xsl. In that stylesheet there is a template xsl:template match="/". As a first child of the template just add:
In this way you will see the entire XML which gets processed by the stylesheet in the Oxygen console and then copy/paste it and set it to a new XML file.
Then you can use the Oxygen debugger to debug that XML file against the XSL and set breakpoints, evaluate expressions and maybe get a better understanding of what's going on.
We have a video demonstration using the debugger:
http://www.oxygenxml.com/demo/XSLTDebug ... ugger.html
Regards,
Radu
If you open a DITA topic in Oxygen (let's say Author page) and you have the caret in a paragraph the Attributes View should be showing for the paragraph the attribute class with the value - topic/p .Ok so does every topic intrinsically have a link class attribute in it, or is it assigned by something?
That attribute is not specified in the XML file but comes as a default value from the topic's DTD. All the DITA OT stylesheets have templates matching these class attribute values instead of the actual element names. In this way you can make specializations and have your own tag name for p and still the output would render it as a paragraph if the class attribute has the same value.
In the same way the DITA link element has a default class attribute of - topic/link .
If you know DTD you can find some of the default class values assignments here:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/dtd/dita132/topic_class.ent
About the xsl:messages:
The #### message is in an xsl:when and the @@@@ is in the xsl:otherwise so of course only one message appears, depending on the decision which is taken in the xsl:when test="*[@href][@role='parent']". In your case the expression probably evaluates to true so the xsl:when body is executed.
About the <div class="parentlink"><xsl:apply-templates select="."/>. The xsl:apply-templates executes all templates matching the current context node. See more details here:http://www.w3schools.com/XSL/el_apply-templates.asp
My advice to you:
The stylesheet which gets applied first on the processed XML input is probably dita2htmlImpl.xsl. In that stylesheet there is a template xsl:template match="/". As a first child of the template just add:
Code: Select all
############################1
<xsl:copy-of select="."/>
############################2
Then you can use the Oxygen debugger to debug that XML file against the XSL and set breakpoints, evaluate expressions and maybe get a better understanding of what's going on.
We have a video demonstration using the debugger:
http://www.oxygenxml.com/demo/XSLTDebug ... ugger.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 58
- Joined: Fri Sep 12, 2008 12:12 am
Re: Editing rel-links for HTML output
Hi Radu,

Thanks,
~Josh
Thanks for the tip on the DTD and for explaining that to me. I'm slowly piecing it all together.Radu wrote: If you open a DITA topic in Oxygen (let's say Author page) and you have the caret in a paragraph the Attributes View should be showing for the paragraph the attribute class with the value - topic/p .
...
If you know DTD you can find some of the default class values assignments here:
OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/dtd/dita132/topic_class.ent

Thanks Radu. I'll try some of that out. Part of this is my fault in not knowing XSLT well enough, but I picked up an XSLT book over the weekend and educated myself a little more as to its syntax and operations. Hopefully I'll be able to sift my way through the code with relative ease in the near future.About the <div class="parentlink"><xsl:apply-templates select="."/>. The xsl:apply-templates executes all templates matching the current context node. See more details here:http://www.w3schools.com/XSL/el_apply-templates.asp
My advice to you:
...
We have a video demonstration using the debugger:
http://www.oxygenxml.com/demo/XSLTDebug ... ugger.html
Thanks,
~Josh
Return to “General XML Questions”
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