我有一个XML图形,包含以下类型:
<xs:simpleType name="valuelist">
<xs:list itemType="xs:double"/>
</xs:simpleType>
样本XML碎片将:
<values>1 2 3.2 5.6</values>
在一项《制止危及海上航行安全非法行为公约》的转变中,我如何掌握名单上的内容?
我如何回避这些内容?
我有一个XML图形,包含以下类型:
<xs:simpleType name="valuelist">
<xs:list itemType="xs:double"/>
</xs:simpleType>
样本XML碎片将:
<values>1 2 3.2 5.6</values>
在一项《制止危及海上航行安全非法行为公约》的转变中,我如何掌握名单上的内容?
我如何回避这些内容?
I. XPath 2.0 (XSLT 2.0) Solutions:
count(tokenize(., ))
II. XPath 1.0 (XSLT 1.0) solution:
string-length()
-
string-length(translate(normalize-space(), , ))
+ 1
As for iteration over the items of this list:
select
attribute:纽约总部
for $i in tokenize(., ),
$n in number($i)
return
yourXPathExpression
纽约总部
2.
In XSLT 1.0 you need to have some more code for splitting/tokenization. There are several good answers to this question (part of them mine) 纽约总部 just search for something like "xslt split a string"
如果名单严格限时,你可以按长处计算面积。
<values>1 2 3.2 5.6</values>
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="string-length(values)
- string-length(translate(values, , )) + 1"/>
</xsl:template>
</xsl:stylesheet>
挑拨你必须分拨这种扼杀。 在SO中有很多例子。
在软件转换中,使用<代码>(数据(价值))代码>。
With a little imagination you can write your own split function :
<xsl:stylesheet version = 1.0 xmlns:xsl= http://www.w3.org/1999/XSL/Transform >
<xsl:output method= text />
<xsl:template name="split-list">
<xsl:param name="list" />
<xsl:param name="separator"/>
<xsl:variable name="newlist" select="concat(normalize-space($list), $separator)" />
<xsl:variable name="first" select="substring-before($newlist, $separator)" />
<xsl:variable name="remaining" select="substring-after($newlist, $separator)" />
<xsl:message terminate="no">
<xsl:value-of select="$first" />
</xsl:message>
<xsl:if test="$remaining">
<xsl:call-template name="split-list">
<xsl:with-param name="list" select="$remaining" />
<xsl:with-param name="separator" select="$separator"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="/">
<xsl:variable name="myList">
1 2 3.2 5.6
</xsl:variable>
<xsl:call-template name="split-list">
<xsl:with-param name="list" select="$myList" />
<xsl:with-param name="separator">
<xsl:text> </xsl:text>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
产出:
[xslt] Loading stylesheet D:ToolsStackOverFlow est.xslt
[xslt] 1
[xslt] 2
[xslt] 3.2
[xslt] 5.6
I ve been wrestling with eBay s Large Merchant Services API for a while. It s been rough. I finally have messages going all the way through their system, but I m having issues with their schema. ...
Does anyone know how to validate a DataTable against a particular DataTable XSD (Schema)? Which would be the best performance-optimized way of doing this? For example: <?xml version="1.0" ...
I m trying to figure out how to correct his deprecated xml schema validation code. public static bool ValidateXml(string xmlFilename, string schemaFilename) { ⁞ //Forward stream reading ...
What is the XSD syntax, given <xs:element name="PhoneNumber" type="xs:string" ...? > , to specify the following format for a phone number: 12 characters and area code is digits. example of ...
What is the easiest way to obtain a statically typed representation of an XML schema (.XSD) in Java? More specifically I want to be able to programatically traverse all defined simpleType:s and ...
I ve inherited the task of creating a schema for some XML which already exists - and IMHO is not the best that could have been done. The section giving me problems is the element at the end of the ...
I m using XmlSerializer to deserialize Xml achives. But I found the class xsd.exe generated only offers capability to read the xml, but no validation. For example, if one node is missing in a document,...
I need a regex for four-digit numbers separated by comma ("default" can also be a value). Examples: 6755 3452,8767,9865,8766,3454 7678,9876 1234,9867,6876,9865 default Note: "default" ...