我在让我的 XML 使用 EXSLT str:replace 模板正确转换时遇到问题。
这是我的 XML:
<XML>
<Item>
<Field>
<Name>ID</Name>
<Value>98765</Value>
</Field>
<Field>
<Name>ParentID</Name>
<Value>10002</Value>
</Field>
<Field>
<Name>Type</Name>
<Value>content</Value>
</Field>
<Field>
<Name>Name</Name>
<Value>TestAPI Course</Value>
</Field>
<Field>
<Name>URL</Name>
<Value></Value>
</Field>
<Field>
<Name>Description</Name>
<Value>a description</Value>
</Field>
<Field>
<Name>DateBegin</Name>
<Value>2012-04-04T00:00:00.000-07:00</Value>
</Field>
<Field>
<Name>DateEnd</Name>
<Value>2012-04-04T00:00:00.000-08:00</Value>
</Field>
<Field>
<Name>DateCreated</Name>
<Value>2012-04-03T00:00:00.000-07:00</Value>
</Field>
<Field>
<Name>DateModified</Name>
<Value>2012-04-04T00:00:00.000-06:00</Value>
</Field>
</Item>
这是我的 XSL:
<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:str="http://exslt.org/strings" extension-element-prefixes="str" version="1.0">
<xsl:import href="C:\inetpub\wwwroot\LMSConnector\LMS\XSL\str.xsl"/>
<xsl:template match="/Items">
<xsl:call-template name="str:replace">
<xsl:with-param name="string" select="Field/Name"/>
<xsl:with-param name="search" select="ID"/>
<xsl:with-param name="replace" select="sco-id"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
我的问题是我只得到一个 XML 文档标题,没有别的,但没有别的?我认为我离一个可行的解决方案还差得很远,问题可能在于我为模板上的“匹配”参数设置的值,以及带有参数节点的调用模板中的选择参数。
任何帮助,将不胜感激。
麦克风