[英]Audience value not exporting to output file in XSLT transform
在 DITA map 上運行 XSLT 轉換時,我無法讓受眾標簽中的值出現在我的 output 文件中。
這是我輸入audience="Alaska"
的片段:
<topicgroup>
<topichead navtitle="Alaska Property and Casualty Adjuster Law" locktitle="yes" audience="Alaska">
<topicgroup>
<mapref href="Qbank/maps/Adj_Unit_AK.ditamap" format="ditamap"/>
</topicgroup>
</topichead>
</topicgroup>
這是我的 XSLT 腳本的一部分,其中包含<!--Add audience-->
部分:
<xsl:template match="topichead">
<xsl:param name="all_topic_refs" select="topicref[@type='topic' or @type='concept']" as="element()*"/>
<xsl:param name="all_question_refs" select="topicref[@type='question']" as="element()*"/>
<xsl:param name="all_exam_refs" select="topicref[@type='exam']" as="element()*"/>
<xsl:param name="audience" select="topichead[@audience='property' or @type='concept']" as="element()*"/>
<xsl:param name="all_exam_maps" select="descendant-or-self::examMap" as="element()*"/>
<xsl:copy>
<xsl:attribute name="navtitle">
<xsl:choose>
<xsl:when test="navtitle">
<xsl:apply-templates select="navtitle"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@navtitle"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<!--Add audience-->
<xsl:attribute name="audience">
<xsl:value-of select="@audience"/>
</xsl:attribute>
<xsl:apply-templates select="*[not(self::examMap[@assessment_type='test-exam-primary']) and not(self::navtitle)]">
<xsl:with-param name="all_topic_refs" select="$all_topic_refs"/>
<xsl:with-param name="all_question_refs" select="$all_question_refs"/>
<xsl:with-param name="all_exam_refs" select="$all_exam_refs"/>
<xsl:with-param name="all_exam_maps" select="$all_exam_maps"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
output 在 Audience 標簽中用空引號給我這個:
<topichead navtitle="Alaska Property and Casualty Adjuster Law" audience="">
<topicref href="questions/inslic_assess_Adj_AK.dita"/>
</topichead>
它正確地拉過導航標題,但我不明白為什么它不會拉過觀眾的輸入。 非常感激任何的幫助。
這是完整的輸入文件:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE bookmap PUBLIC "-//OASIS//DTD DITA BookMap//EN" "bookmap.dtd" []>
<bookmap>
<booktitle>
<mainbooktitle>Property & Casualty Insurance Adjuster Qbank</mainbooktitle>
</booktitle>
<bookmeta>
<category>course</category>
<!-- <category> will describe type of map it is (qbank, course w/final exam, final exam, etc) -->
<prodinfo>
<prodname>Insurance Adjuster Licensing</prodname>
<vrmlist>
<vrm version="2022"/>
</vrmlist>
<brand>lic</brand>
<series>adjqbank</series>
</prodinfo>
<bookid>
<bookpartno>00012345</bookpartno>
</bookid>
</bookmeta>
<!--
# Transform Type: LMS_Transform
# DITAVAL: USstate_National_Short_Adjuster_Digital_InsLic.ditaval
# File Path to Final Zip: G:\Shared drives\DITA Zip Files\Insurance Licensing\Property & Casualty\20535_National Insurance Adjuster Solution
# Reltable: N
# Glossary notes: Y/N
# Run from main folder?: N
# PDF: Standard
-->
<chapter href="Qbank/topics/Adj_Qbank_1.dita" locktitle="yes">
<topicmeta>
<navtitle>Property & Casualty Insurance Adjuster</navtitle>
</topicmeta>
<topicgroup>
<topichead navtitle="Introduction to Insurance" locktitle="yes">
<topicgroup>
<mapref href="Qbank/maps/Adj_Unit_1.ditamap" format="ditamap"/>
</topicgroup>
</topichead>
</topicgroup>
<topicgroup>
<topichead navtitle="Contracts" locktitle="yes">
<topicgroup>
<mapref href="Qbank/maps/Adj_Unit_2.ditamap" format="ditamap"/>
</topicgroup>
</topichead>
</topicgroup>
</chapter>
<chapter href="Qbank/topics/Adj_Qbank_State_Specific.dita" locktitle="yes">
<topicmeta>
<navtitle>State Regulations</navtitle>
</topicmeta>
<topicgroup>
<topichead audience="Alabama" navtitle="Alabama Property and Casualty Adjuster Law" locktitle="yes">
<topicgroup>
<mapref href="Qbank/maps/Adj_Unit_AL.ditamap" format="ditamap"/>
</topicgroup>
</topichead>
</topicgroup>
<topicgroup>
<topichead navtitle="Alaska Property and Casualty Adjuster Law" locktitle="yes" audience="Alaska">
<topicgroup>
<mapref href="Qbank/maps/Adj_Unit_AK.ditamap" format="ditamap"/>
</topicgroup>
</topichead>
</topicgroup>
<topicgroup>
<topichead navtitle="Arizona Property and Casualty Adjuster Law" locktitle="yes" audience="Arizona">
<topicgroup>
<mapref href="Qbank/maps/Adj_Unit_AZ.ditamap" format="ditamap"/>
</topicgroup>
</topichead>
</topicgroup>
</chapter>
</bookmap>
這是刪除了不相關內容的完整腳本:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:functx="http://www.functx.com"
xmlns:ditaarch="http://dita.oasis-open.org/architecture/2005/"
exclude-result-prefixes="xs functx ditaarch" version="2.0">
<xsl:import href="functx-1.0.xsl"/>
<xsl:import href="new_topic_task.xsl"/>
<xsl:param name="BASE_DIR"/>
<xsl:param name="OUT_DIR"/>
<xsl:output encoding="UTF-8" method="xml" indent="yes"
doctype-public="-//OASIS//DTD DITA Map//EN" doctype-system="map.dtd"/>
<xsl:strip-space elements="*"/>
<!-- Create a global variable so that we can refer back to the supermap. -->
<xsl:variable name="supermap" select="/supermap" as="element()*"/>
<!-- Create a global variable so that we can refer back to the los. -->
<xsl:variable name="los_summary" select="/supermap/los_summary" as="element()*"/>
<xsl:template match="/">
<xsl:apply-templates select="supermap"/>
</xsl:template>
<xsl:template match="supermap">
<map>
<xsl:attribute name="title">
<xsl:value-of select="@title"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="@id"/>
</xsl:attribute>
<!-- Handle topicheads. -->
<xsl:apply-templates select="topichead"/>
<!-- Create the final exam map outside all other topic heads. -->
<xsl:apply-templates select="topichead[@unit_map_type='final-exam']/examMap">
</xsl:apply-templates>
<!-- Handle LOS. -->
<xsl:apply-templates select="los_summary"/>
</map>
</xsl:template>
<!-- Top level topichead. -->
<xsl:template match="topichead">
<!-- Made these parameters so that subordinate topicheads behave correctly...I think. -->
<xsl:param name="all_topic_refs" select="topicref[@type='topic' or @type='concept']" as="element()*"/>
<xsl:param name="all_question_refs" select="topicref[@type='question']" as="element()*"/>
<xsl:param name="all_exam_refs" select="topicref[@type='exam']" as="element()*"/>
<xsl:param name="audience" select="topichead[@audience='property' or @type='concept']" as="element()*"/>
<!-- Added for QBank -->
<xsl:param name="all_exam_maps" select="descendant-or-self::examMap" as="element()*"/>
<!-- [SP] 2015-01-13: Don't display topichead in qbank output. -->
<xsl:choose>
<xsl:when test="@unit_map_type = 'qbank'">
<xsl:apply-templates select="*[not(self::examMap[@assessment_type='test-exam-primary'])]">
<xsl:with-param name="all_topic_refs" select="$all_topic_refs"/>
<xsl:with-param name="all_question_refs" select="$all_question_refs"/>
<xsl:with-param name="all_exam_refs" select="$all_exam_refs"/>
<xsl:with-param name="all_exam_maps" select="$all_exam_maps"/>
</xsl:apply-templates>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:attribute name="navtitle">
<xsl:choose>
<xsl:when test="navtitle">
<xsl:apply-templates select="navtitle"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@navtitle"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<!--Add audience-->
<xsl:attribute name="audience">
<xsl:value-of select="@audience"/>
</xsl:attribute>
<xsl:apply-templates select="*[not(self::examMap[@assessment_type='test-exam-primary']) and not(self::navtitle)]">
<xsl:with-param name="all_topic_refs" select="$all_topic_refs"/>
<xsl:with-param name="all_question_refs" select="$all_question_refs"/>
<xsl:with-param name="all_exam_refs" select="$all_exam_refs"/>
<xsl:with-param name="all_exam_maps" select="$all_exam_maps"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
當使用 DITA Open Toolkit 發布 DITA XML 內容時,我假設您的 XSLT 樣式表在某個階段從插件應用。 您可以在 xsl:template 中添加一個 xsl:message 來匹配 topichead:
<xsl:message><xsl:copy-of select="."/></xsl:message>
然后在發布時查看控制台 output 以准確查看模板應用在哪個 XML 元素上。 DITA Open Toolkit 發布引擎有一個預處理步驟,它應用過濾並從所有元素中刪除所有分析屬性。 https://www.dita-ot.org/dev/reference/preprocess-debugfilter.html
要在發布時保留分析屬性,您需要指定一個 DITAVAL 過濾器文件,該文件指定分析屬性應傳遞給已發布的 output。類似於:
<val>
<prop action="passthrough" att="audience"/>
</val>
https://www.oxygenxml.com/dita/1.3/specs/langRef/ditaval/ditaval-prop.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.