xslt 相关问题

XSLT是XML的一种转换语言,旨在将结构化文档转换为其他格式(如XML,HTML和纯文本,或者在XSLT 3,JSON中)。问题应该根据需要使用xslt-1.0,xslt-2.0或xslt-3.0标记之一。

如何使用Unicode翻译特殊字符并在同一选择中正确显示和正确显示block

端目标:使用o,u的替换/翻译值正确显示所有名称,代替umlauts,并且仍然显示&正确地显示,而不仅仅是用于单个办公室值,例如Test&Welcome。

回答 1 投票 0

无法弄清楚如何使用XSL变量

我想要... 我使用XMLSTARLET,并花了数小时的时间阅读而没有成功。我在XML中有这个: <person pcode="sherry-smith">Sherry Smith</person> <day>14</day>

回答 1 投票 0

加载允许的XML属性值到放松NG语法文件

<element name="language"> <externalRef href="language.rng"/> </element>

回答 1 投票 0

使用键/模板在XSLT

以下XML文档正在通过XSLT查找: 以下XML文档正在通过XSLT查找: <?xml version="1.0"?> <Generic> <SalesOrgProperties_HashMap> <item key="1003" value="3660,00,C0"/> <item key="1005" value="3670,00,L0"/> <item key="1214" value="4200,00,L0"/> </SalesOrgProperties_HashMap> <CondType_PriceListDiscount_HashMap> <item key="1003" value="ZL99"/> <item key="1005" value="ZL99"/> <item key="1214" value="ZL99"/> <item key="1227" value="ZL99"/> </CondType_PriceListDiscount_HashMap> <CondType_NetAmount_HashMap> <item key="1003" value="ZAF2"/> <item key="1005" value="ZAF2"/> <item key="1214" value="ZPVP"/> <item key="1227" value="ZAF2"/> </CondType_NetAmount_HashMap> <CondType_GrossPrice_HashMap> <!--<item key="1003" value="ZHTI"/>--> <item key="1005" value="ZHTI"/> <item key="1214" value="ZHTI"/> <item key="1227" value="ZHTI"/> </CondType_GrossPrice_HashMap> </Generic> 采用查找操作的块是: <xsl:key name="SO_ReplaceFunction" match="item" use="@key"/> <xsl:variable name="SO_Properties" select="document($LookupDocument)/Generic/SalesOrgProperties_HashMap"/> <xsl:key name="CondType_PriceListDiscount_ReplaceFunction" match="item" use="@key"/> <xsl:variable name="CondType_PriceListDiscount_Properties" select="document($LookupDocument)/Generic/CondType_PriceListDiscount_HashMap"/> <xsl:key name="CondType_NetAmount_ReplaceFunction" match="item" use="@key"/> <xsl:variable name="CondType_NetAmount_Properties" select="document($LookupDocument)/Generic/CondType_NetAmount_HashMap"/> <xsl:key name="CondType_GrossPrice_ReplaceFunction" match="item" use="@key"/> <xsl:variable name="CondType_GrossPrice_Properties" select="document($LookupDocument)/Generic/CondType_GrossPrice_HashMap"/> 定义的模板: <xsl:template match="SalesOrgProperties_HashMap"> <xsl:param name="valueToLookup"/> <xsl:value-of select="key('SO_ReplaceFunction', $valueToLookup)/@value"/> </xsl:template> <xsl:template match="CondType_PriceListDiscount_HashMap"> <xsl:param name="valueToLookup"/> <xsl:value-of select="key('CondType_PriceListDiscount_ReplaceFunction', $valueToLookup)/@value"/> </xsl:template> <xsl:template match="CondType_NetAmount_HashMap"> <xsl:param name="valueToLookup"/> <xsl:value-of select="key('CondType_NetAmount_ReplaceFunction', $valueToLookup)/@value"/> </xsl:template> <xsl:template match="CondType_GrossPrice_HashMap"> <xsl:param name="valueToLookup"/> <xsl:value-of select="key('CondType_GrossPrice_ReplaceFunction', $valueToLookup)/@value"/> </xsl:template> 和一个示例应用程序: <xsl:apply-templates select="$CondType_PriceListDiscount_Properties"> <xsl:with-param name="valueToLookup" select="$salesOrg"/> </xsl:apply-templates> 看到的输出为: ,我期待这个:zl99的输入1214。 任何想知道我怎么了?谢谢 您的表达太通用了。它与所有/所有元素匹配,您需要将其限制在特定的hashmap元素的孩子中。 例如: xsl:key/@match

回答 1 投票 0



如何使用XSLT 3.0?

的主要元素。我在文档中其他地方还有其他元素,其中包含我要添加的信息的信息

回答 1 投票 0

完全,然后立即粘贴原件。 ...

<x>...</x>,然后立即粘贴原件。 我对标签内部的内容或结构没有任何先验知识,但我确实知道该标签的xpath。

回答 4 投票 0

我正在尝试使用XML样式表为我的RSS XML添加HTML音频播放器。这是通过添加

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"> <xsl:output method="html" version="1.0" encoding="ISO-8859-1" indent="yes"/> <xsl:template match="/"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><xsl:value-of select="/rss/channel/title"/> - RSS</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> @import url('https://fonts.googleapis.com/css?family=Montserrat:300,400,500,600'); @import url("https://use.fontawesome.com/releases/v5.8.1/css/all.css"); body { font-family: 'Montserrat', sans-serif; font-size: 14px; color: #545454; background: #E5E5E5; line-height: 1.5; } .explanation { font-style: italic; font-size: 10px; color: #9E9E9E; text-align: center; } a, a:link, a:visited { color: #005C82; text-decoration: none; } a:hover { color: #000; } h1 { margin-top: 0; margin-bottom: 0; font-weight: 300; font-size: xx-large; } h2, h3 { margin-top: 0; margin-bottom: 0px; font-weight:300; } h2 { margin-top: 20px; } h3 { font-size:small; font-weight: 500; } img { max-width: 100%; } #content { max-width: 900px; margin: 0 auto; background: #FFF; padding: 30px; border-radius: 1em; padding-top: 0px; box-shadow: 0px 0px 2px #5D5D5D; } #channel-image { float: right; width: 200px; margin-bottom: 20px; } #channel-image img { width: 200px; height: auto; border-radius: 3px; margin-left: 10px; } #channel-header { margin-bottom: 20px; padding-top: 20px; margin-left: -10px; } .channel-item { clear: both; border-top: 2px solid #E5E5E5; margin: 10px; overflow-wrap: break-word; word-wrap: break-word; hyphens: auto; } .episode-image { float: right; width: 300px; margin-right: 10px; margin-bottom: 10px; margin-top: 10px; } .episode-image img { width: 300px; height: auto; border-radius: 5px; } .episode-title { margin-bottom:20px; } .episode_meta { font-size: 11px; font-weight: 500; margin-top: 20px; margin-bottom: 10px; } .channel-description { margin-bottom: 10px; overflow-wrap: break-word; word-wrap: break-word; hyphens: auto; } .channel-copyright { text-align: center; margin: 10px; font-size: small; } .channel-author { font-size: small; font-weight: 600; margin-bottom: 10px; } .channel-subtitle { font-size: small; font-weight: 500; margin-bottom: 20px; } .fa, .far, .fas { font-family: "Font Awesome 5 Free"; margin-left: 5px; margin-right: 5px; display: initial; } </style> </head> <body> <p class="explanation"> This is a podcast RSS feed generated by <xsl:value-of select="/rss/channel/generator"/>. It is meant for consumption by podcast feed readers using the URL in the address bar. </p> <div id="content"> <div id="channel-header"> <h1> <xsl:if test="/rss/channel/image"> <div id="channel-image"> <img> <xsl:attribute name="src"> <xsl:value-of select="/rss/channel/image/url"/> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="/rss/channel/image/title"/> </xsl:attribute> </img> </div> </xsl:if> <xsl:value-of select="/rss/channel/title"/> </h1> <div class="channel-subtitle"> <xsl:value-of select="/rss/channel/itunes:subtitle" disable-output-escaping="yes"/> </div> <div class="channel-description"> <xsl:value-of select="/rss/channel/description" disable-output-escaping="yes"/> </div> <div class="channel-author"> <xsl:value-of select="/rss/channel/itunes:author" disable-output-escaping="yes"/> <a style="font-size: large;font-weight: 600;"> <xsl:attribute name="href"> <xsl:value-of select="/rss/channel/link"/> </xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <i class="fas fa-globe"></i> </a> </div> </div> <xsl:for-each select="/rss/channel/item"> <div class="channel-item"> <div class="episode-title"> <h2> <a> <xsl:attribute name="href"> <xsl:value-of select="link"/> </xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <xsl:value-of select="title"/> </a> <div class="episode-image"> <img> <xsl:attribute name="src"> <xsl:value-of select="itunes:image/@href"/> </xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="title"/> </xsl:attribute> </img> </div> </h2> <h3> <xsl:if test="itunes:author"> <xsl:value-of select="itunes:author" disable-output-escaping="yes"/> </xsl:if> </h3> </div> <div class="episode-description"> <xsl:if test="description"> <p> <xsl:value-of select="description" disable-output-escaping="yes"/> </p> </xsl:if> </div> <p class="episode_meta"> <a> <xsl:attribute name="href"> <xsl:value-of select="enclosure/@url"/>?ref=new_window </xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <i class="fas fa-download"></i> <xsl:value-of select='format-number(number(enclosure/@length div "1024000"),"0.0")'/>MB </a> | <i class="fas fa-stopwatch"></i> <xsl:value-of select="itunes:duration" disable-output-escaping="yes"/> | <i class="far fa-calendar"></i> <xsl:value-of select="pubDate" /> </p> </div> </xsl:for-each> </div> <div class="channel-copyright"> &#x24B8; <xsl:value-of select="/rss/channel/copyright"/> </div> </body> </html> </xsl:template> </xsl:stylesheet> 对于初学者,我想知道这是否是犹太洁食,还是有更好的方法来通过在XSL文件中添加音频播放器,该音频播放器对于每个帖子都会播放封闭式的帖子是动态的:url。 #noob 您可以在模板中添加类似的东西: <audio controls="controls" src="{enclosure/@url}" preload="none"></audio> 这将是更一般的,因为它即使对于没有音频播放器标签的供稿也可以。 这种使用controls="controls"而不是仅仅用来使其形成良好的XML。

回答 1 投票 0


回答 1 投票 0

在单匹配语句中使用身份转换和多个谓词沉默节点

I正在使用身份转换和模板匹配来重建XML元素。当满足两个谓词条件时,我需要此元素才能选择性地填充,并且我正在尝试这样做...。

回答 0 投票 0

XSLT代码将XML文件拆分为基于XML标签的运行时Mulitple XML文件 <events><id>

AM试图将XML文件分为基于XML标签 /输入XML文件中的多个XML文件。单个输出XML文件应按照输入XML /从输入XML的顶部到底部按顺序进行,XML标签具有唯一的ID。 所有输出单个XML文件应按照输入XML文件为顺序。

回答 0 投票 0

如何将XSLT变量传递给XSLT模板中的JavaScript函数? 我正在使用XSLT,需要将XSLT变量传递给JavaScript函数,以动态更新页面上的内容。具体来说,我的XSLT模板中有一个变量,我想让您...

<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:outline="http://wkhtmltopdf.org/outline" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" indent="yes" /> <xsl:template match="outline:outline"> <html> <head> <title>TOC</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <!-- Note: I want to dynamically update the following h1 by JS --> <h1 id="toc">Table of Contents</h1> <ul id="top"> <xsl:apply-templates select="outline:item/outline:item"/> </ul> <script type="text/javascript"> const languageMap = { 'ENG': 'Table of Contents', 'JPN': '目次', 'CHS': '目录', 'CHT': '目錄' }; <!-- Note: the following function gets the languageTitle from XSLT and replaces h1 with matched value --> function updateTOCHeader(languageTitle) { const tocHeader = document.getElementById('toc'); tocHeader.style.color = "green"; if(languageMap[languageTitle]) { tocHeader.innerText = languageMap[languageTitle]; } } </script> </body> </html> </xsl:template> <xsl:template match="outline:item"> <xsl:choose> <!-- Note: the following if test checks if the ancestor item has a title starting with 'language_title:' --> <xsl:when test="ancestor::outline:item[starts-with(@title, 'language_title:')]"> <xsl:variable name="language_title" select="normalize-space(substring-after(ancestor::outline:item[@title and starts-with(@title, 'language_title:')]/@title, 'language_title:'))"/> <script type="text/javascript"> <!-- Note: call the following function to update the TOC header based on language title --> updateTOCHeader("<xsl:value-of select="$language_title"/>"); </script> </xsl:when> <xsl:otherwise> <li> <xsl:if test="@title != ''"> <div class="{if (outline:item) then 'category-item' else ''}"> <span class="toc-link"> <a> <xsl:if test="@link"> <xsl:attribute name="href"><xsl:value-of select="@link"/></xsl:attribute> </xsl:if> <xsl:value-of select="@title"/> </a> </span> <span class="page-no"> <xsl:value-of select="@page"/> </span> </div> </xsl:if> <ul> <xsl:apply-templates select="outline:item"/> </ul> </li> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>

回答 1 投票 0

如何计算Xquery中变量的功率?

192.168.1.1 如果我需要计算一个变量“ totalipAddress”,其值为2^($ blocksize)的XQUERY语句是什么? <IPaddress> <startIPaddress>192.168.1.1</startIPaddress> <blocksize>4</blocksize> </IPaddress> there是计算功率的一种特别有效的方法 - 具有对数时间复杂性(O(log(n)): declare function local:pow($x as xs:double , $n as xs:integer ) as xs:double { if($n eq 0) then 1 else (let $h := $n idiv 2, $halfResult := local:pow($x, $h) return if($n mod 2 eq 0) then $halfResult * $halfResult else $x * $halfResult * $halfResult ) }; local:pow(2,10) 产生预期的正确结果: 1024 the Recursion是您的朋友: declare function f:two-to-the($n as xs:integer) as xs:integer { if ($n = 0) then 1 else 2 * f:two-to-the($n - 1) }; 数学:POW,最简单的方法就是将其进行硬盘: (1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296)[$blocksize + 1] 工作也在xpath 2中。 有数学:POW函数: 麦片:POW(POW( $ x作为xs:double?, $ y AS XS:数字 )为xs:double?

回答 4 投票 0

为什么XSltProc在十六进制实体中以口音转换字符?

i有一个html文件,称为input.html,我想从其中提取XML片段: 文本与 我应用此XSL样式表,名为Stylesheet.xsl: &l ...

回答 0 投票 0

如何仅使用xpath 3.1?

我有一个戏剧的XML文件,该提取物将提供: lysistrata的cal.tu Mecastor salve。 sed quid

回答 1 投票 0

可逃逸的XML文本传递了槽命令行

概述 我有XML的一部分,他们来自XML(或XSLT本身),因为它是由另一个过程产生的动态性。因此,我将其放入命令行。 问题 WH ...

回答 1 投票 0

限制访问XSL

I正在使用XSL模板,并且此模板具有一个函数Unparsed-Text()。 但是,此无与伦比的text()函数能够访问限制和priate文件夹,例如c/system32 ...有一些方法...

回答 1 投票 0

从分离的模式文件删除示意图验证

我有一个示意图文件,该文件已分开为3个文件。一个文件包含使用代码列表,另一个文件包含详细信息和消息,而另一个则包含这些r ...

回答 1 投票 0

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.