Can't match the topic/pre class
Posted: Sat Aug 27, 2022 4:50 pm
Hello, everyone!
I'm currently trying to write an XSLT that matches a specific outputclass value and depending on the class, I need to display a specific label beforehand.
I rely on a temporary output from a DITA concept.
Here is a short sample:
However, my XSLT doesn't seem to correctly target the class topic/pre or the pr-d/codeblock
Would you have any idea where I'm wrong?
I'm currently trying to write an XSLT that matches a specific outputclass value and depending on the class, I need to display a specific label beforehand.
I rely on a temporary output from a DITA concept.
Here is a short sample:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<concept xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/" xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot" class="- topic/topic concept/concept " ditaarch:DITAArchVersion="1.3" domains="(topic concept) (topic reference) (topic task) (topic concept glossentry) (topic concept glossgroup) (topic troubleshooting++task) (topic task) (topic abbrev-d) a(props deliveryTarget) (topic hazard-d) (topic hi-d) (topic indexing-d) (topic markup-d) (topic pr-d) (topic svg-d) (topic sw-d) (topic ui-d) (topic ut-d) (topic task strictTaskbody-c) a(base xxxxxx_locid) (topic xxxxxx-releasenotes)" id="ptx1649725064918" xml:lang="en-us" xtrc="concept:1;3:49" >
<title class="- topic/title ">Add a label when a specific class is matched</title>
<shortdesc class="- topic/shortdesc ">Lorem Ipsum</shortdesc>
<conbody class="- topic/body concept/conbody ">
<codeblock class="+ topic/pre pr-d/codeblock " id="codeblock_nxc_sjm_dtb" outputclass="collapse-folded">
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"id":"a7d67610-ceb5-4350-ba5a-746472c4f1f7",
"schemas": [
"urn:scim:schemas:core:1.0",
"urn:scim:schemas:com_pingone:1.0"
],
"urn:scim:schemas:com_pingone:1.0": {
"createTimeStamp":1429123454227,
"accountId":"a6538050-412a-4bca-a44d-07deb4b073a8",
"lastModifiedTimeStamp":1429123454227,
"directoryId":"90b3dfe3-f8d0-45ad-8c04-047c88b03137",
"state":"ACTIVE"
},
"groups":[
{
"display":"Users",
"value":"0b854f8d-a291-4e95-ad4b-68474a666e55"
}
]
}
</codeblock>
</conbody>
</concept>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:table="http://dita-ot.sourceforge.net/ns/201007/dita-ot/table"
xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
xmlns:dita2html="http://dita-ot.sourceforge.net/ns/200801/dita2html"
xmlns:related-links="http://dita-ot.sourceforge.net/ns/200709/related-links"
exclude-result-prefixes="#all">
<xsl:template match="*[contains(@outputclass, 'collapse-folded')]">
<xsl:choose>
<xsl:when test="
*[contains(@class, ' topic/pre ')]
or *[contains(@class, ' pr-d/codeblock ')]
">
<br/>
<span class="ft-expanding-block-link" style="color: red; font-weight: bold;">
Show code block
</span>
</xsl:when>
<xsl:otherwise>
<h1>CLASS DETECTION IS NOT WORKING</h1>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>