我有以下XSLT
<xsl:param name="productsId" select="/macro/productsId" />
<xsl:param name="type" select="/macro/type" /> <!-- value1, value2, value3 -->
<xsl:template match="/">
<xsl:if test="$productsId > 0">
<xsl:variable name="products" select="umbraco.library:GetXmlNodeById($productsId)" />
<div id="carousel-wrap">
<ul id="carousel">
<xsl:for-each select="$products/Product [select only Product with attribute value1, value2 or value3 based on /macro/type]">
<li id="p-{@id}">
<xsl:variable name="title">
<xsl:choose>
<xsl:when test="string-length(productHeading) > 0">
<xsl:value-of select="productHeading" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@nodeName" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{umbraco.library:NiceUrl(@id)}">
<!-- Image -->
<xsl:if test="productImage > 0">
<xsl:variable name="productImage" select="umbraco.library:GetMedia(productImage, 0)" />
<img src="/ImageGen.ashx?image={$productImage/umbracoFile}&height=131" />
</xsl:if> …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个列出电影的XSLT,我正在设计标题,以便每个标题都有自己的颜色,然后用插值选择标题(XPath?)
这是XSL文件:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Videos</title>
<style>
table, tr, td { border: thin black solid }
th { background-color: #AAFFAA }
.Daredevil { color: red; }
/* Look at those spaces! Hrmphf! */
.Drag Me To Hell { color: green; }
</style>
</head>
<body>
<table>
<tr><th>Movies</th></tr>
<xsl:apply-templates select="//movie"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="//movie[not(@title=preceding::movie/@title)]">
<!-- Title should be the one of the titles in the CSS -->
<tr class="{@title}"><td><xsl:value-of select="@title"/></td></tr>
</xsl:template>
</xsl:stylesheet> …Run Code Online (Sandbox Code Playgroud) 在XSLT程序中的某个时刻,我有以下内容:
<xsl:for-each select="tags/tag">
<xsl:apply-templates select="//shows/show[film=//films/film[tag=current()/@id]/@id]|//shows/show[group=//groups/group[film=//films/film[tag=current()/@id]/@id]/@id]">
<xsl:sort select="date" data-type="text" order="ascending"/>
<xsl:sort select="time" data-type="text" order="ascending"/>
</xsl:apply-templates>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
似乎XPath表达式//shows/show[film=//films/film[tag=current()/@id]/@id]|//shows/show[group=//groups/group[film=//films/film[tag=current()/@id]/@id]/@id]相当复杂,大大减慢了程序的执行速度(与添加引用代码之前的执行时间相比 - 当然是处理相同的数据).
你认为这是正常的,因为表达的性质相对复杂,你是否看到我如何改进它以使其表现更好?
注意:在XPath表达式中,film和//films/film,group并//groups/group引用不同的元素.
请参阅下面的XML输入的精简样本.
<program>
<tags>
<tag id="1">Tag1</tag>
<tag id="2">Tag2</tag>
<tag id="3">Tag3</tag>
</tags>
<films>
<film id="1">
Film1
<tag>2</tag><!-- References: /program/tags/tag/@id=2 -->
</film>
<film id="2">
Film2
<tag>1</tag><!-- References: /program/tags/tag/@id=1 -->
</film>
<film id="3">
Film3
<tag>3</tag><!-- References: /program/tags/tag/@id=3 -->
</film>
<film id="4">
Film4
<tag>3</tag><!-- References: /program/tags/tag/@id=3 -->
</film>
</film>
<groups>
<group id="1">
<film>3</film><!-- References: /program/films/film/@id=3 …Run Code Online (Sandbox Code Playgroud) 我以前从未真正使用过XSLT,我正在寻找一些建议.
我从GSA框中以XML格式返回以下项目:
<MT N="searchCategories" V="Category 1"/>
<MT N="searchCategories" V="Category 2"/>
etc etc
Run Code Online (Sandbox Code Playgroud)
可以有任何数量的这些类别.
我只是想知道XSLT是否有任何数组概念?
如果是这样:
如果不:
我相信我使用的是XSLT 1.0版
我有一个包含25个元素的XML文件.我只想转换2个元素并保留剩余的XML.有人可以告诉我该怎么做.在线的所有例子都是整个修改xml doc,我不想要这个.我只想修改两个元素的值.
正如我之前所说,我已经开始学习XSLT了
当我正在努力时,我得到了错误的XML格式
输入
<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig note-ref="no">
<access-panel>113AL</access-panel>
<access-panel>119AL</access-panel>
</testingcongif>
Run Code Online (Sandbox Code Playgroud)
产量
<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig>
<panel><panelid>113AL</panelid></panel>
<panel><panelid>119AL</panelid></panel>
</testingconfig>
Run Code Online (Sandbox Code Playgroud)
我的XSL
<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig>
<xsl:for-each select="testingconfig">
<panel>
<panelid>
<xsl:value-of select="*"/>
</panelid>
</panel>
</xsl:for-each>
</testingconfig>
Run Code Online (Sandbox Code Playgroud)
出于这个原因
<testingconfig>
<panel>
<panelid>
113AL 119AL
</panelid>
</panel>
</testingconfig>
Run Code Online (Sandbox Code Playgroud)
任何人都可以在这里帮助我,我在做错误,请帮助我在XSLT 2.0中如何做到这一点
请帮助我
谢谢和问候M.
我有一个XML数据文档,其中包含名为"folio"的嵌套标记.它可以嵌套标签的最大级别是4.我需要递归处理每个作品集,直到我达到没有嵌套作品集并打印内容的级别.
我不确定如何在XSL中进行递归.这是一个示例文档.sombody可以帮忙吗?
谢谢.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<reporting:root xmlns:reporting="http://www.xyzcorp.net/reporting">
<reporting:default0 reporting:type="Portfolio">
<reporting:header>
<reporting:configuration>
<reporting:columns>
<reporting:column reporting:group="instrument" reporting:name="Ident" reporting:tag="ident" reporting:type="int"/>
<reporting:column reporting:group="prices" reporting:name="Last (Time)" reporting:tag="lastTime" reporting:type="string"/>
<reporting:column reporting:group="noGroup" reporting:name="RIC" reporting:tag="ric" reporting:type="string"/>
<reporting:column reporting:group="instrument" reporting:name="Reference" reporting:tag="reference" reporting:type="string"/>
<reporting:column reporting:group="result" reporting:name="Currency" reporting:tag="currency" reporting:type="string"/>
</reporting:columns>
</reporting:configuration>
</reporting:header>
<reporting:window reporting:Id="36674" reporting:level="0" reporting:name="MY_PORTFOLIO" reporting:parentId="11991">
<reporting:folio>
<reporting:folioid>1234</reporting:folioid>
<reporting:folio>
<reporting:folioid>9876</reporting:folioid>
<reporting:line reporting:Id="67520135" reporting:level="1" reporting:name="INTERNATIONAL BUSINESS MACHINES CORP" reporting:parentId="36674" reporting:positionType="0">
<reporting:ident>643633</reporting:ident>
<reporting:reference>IBM.USD</reporting:reference>
<reporting:currency>USD</reporting:currency>
</reporting:line>
<reporting:line reporting:Id="67520179" reporting:level="1" reporting:name="GENERAL ELECTRIC CO" reporting:parentId="36674" reporting:positionType="0">
<reporting:ident>643635</reporting:ident>
<reporting:ric>GE.N</reporting:ric>
<reporting:reference>GE.USD</reporting:reference>
<reporting:currency>USD</reporting:currency>
</reporting:line>
</reporting:folio> …Run Code Online (Sandbox Code Playgroud) 我有XSLT喜欢:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
.......
<xsl:value-of select="format-number(abs(QUANTITY), '#')"/>
....
Run Code Online (Sandbox Code Playgroud)
它与Altova XMLSpy等工具完美配合,但当我尝试从.Net进行转换时:
XslTransform myXslTransform = new XslTransform();
myXslTransform.Load("some.xls");
myXslTransform.Transform(@"inputxml", @"c:\out.csv");
Run Code Online (Sandbox Code Playgroud)
它抛出异常
System.Xml.Xsl.XsltException was unhandled
Message='abs()' is an unknown XSLT function.
Source=System.Data.SqlXml
Run Code Online (Sandbox Code Playgroud)
我知道ABS是一个足够简单的功能来实现,但问题是为什么它会发生在.Net上?
有人有什么想法吗?
我是XSL转换的新手。我在哪里尝试使用XSLT提取XML的一部分。
源XML
<tree>
<trunk>
<branch>
<leaves></leaves>
<flowers></flowers>
<fruits></fruits>
</branch>
</trunk>
</tree>
Run Code Online (Sandbox Code Playgroud)
我期望以下XML作为输出
<root>
<branch>
<leaves></leaves>
<flowers></flowers>
<fruits></fruits>
</branch>
</root>
Run Code Online (Sandbox Code Playgroud)
请提供转换,我长期以来一直在做一些随机的事情。
我在输入xml文件中有一个noumber,如19778.40,但我想通过xslt在输出xml文件中更改为19778,40(逗号而不是点).
我该如何格式化这个数字?我不想为它使用任何模板.