我用XmlDataSource这样的:
<asp:XmlDataSource ID="xmlDataSource1" runat="Server" DataFile="https://myurl.xml" ></asp:XmlDataSource>
Run Code Online (Sandbox Code Playgroud)
作为我rotater控制的数据源.
但我一直得到以下例外:
https://myurl.xml不是有效的虚拟路径.
虽然我在外部尝试了链接,但是有一个xml文件
我正在尝试转换此XML: -
<list>
<unit>
<data1>a</data1>
<data2>b</data2>
<data3>c</data3>
</unit>
</list>
Run Code Online (Sandbox Code Playgroud)
对此: -
<list>
<unit>
<category1>
<data1>a</data1>
<data2>b</data2>
</category1>
<category2>
<data3>c</data3>
</category2>
</unit>
</list>
Run Code Online (Sandbox Code Playgroud)
使用XSL.我正在使用以下XSL: -
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="some_namespace">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="//s:unit" xml:space="preserve">
<xsl:copy>
<category1>
<xsl:apply-templates select="./s:data1"/>
<xsl:apply-templates select="./s:data2"/>
</category1>
<category2>
<xsl:apply-templates select="./s:data3"/>
</category2>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
现在,这保留了内部的缩进,但完全混淆了列表.这就是我得到的: -
<list>
<unit>
<category1>
<data1>a</data1>
<data2>b</data2>
</category1>
<category2>
<data3>c</data3>
</category2>
</unit>
</list>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
如何使用Xpath仅查找至少具有相似/相等的兄弟节点的节点?
例如:
<root>
<parent>
<node>...</node>
<node_unique>...</node_unique>
<node>...</node>
<another_one>...</another_one>
<another_one>...</another_one>
</parent>
</root>
Run Code Online (Sandbox Code Playgroud)
在示例中,xpath shold仅选择<node>,<another_one>因为它们出现的次数不止一次.
我试图找到一个解决方案几个小时没有成功(现在我认为XPath不可能...).
这是变量:
<xsl:variable name="WepNr" select="/*/DbResponse/ResultSet/Row[Cell[@name='ARTNR']=$ArtNr][Cell[@name='WEANR']=$WeaNr]/Cell[@name='WEPNR']"/>
Run Code Online (Sandbox Code Playgroud)
它可以返回多个值,因此在这种情况下,它将输出类似于:2 21 36= 3个值的内容.
我试着通过它们:
<xsl:for-each select="$WepNr">
<LineNumber><xsl:value-of select="$WepNr"/></LineNumber>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
但它只输出2 21 36三次相同的值:
<LineNumber>2 21 36</LineNumber>
<LineNumber>2 21 36</LineNumber>
<LineNumber>2 21 36</LineNumber>
Run Code Online (Sandbox Code Playgroud)
如何输出3次像:
<LineNumber>2</LineNumber>
<LineNumber>21</LineNumber>
<LineNumber>36</LineNumber>
Run Code Online (Sandbox Code Playgroud)
?
我正在使用一个返回属性信息的API。一些文本信息存储在子节点之间,我想将其连接为单个字符串(VARCHAR)。
我的过程是,我通过Web服务获取xml,然后将其传递给proc,该proc提取xml值并将其插入到视图中,这是我返回的xml的代码段:
<properties>
<property propertyid="1234">
<bullets>
<bullet>nice garden</bullet>
<bullet>it smells a bit</bullet>
<bullet>body under the patio</bullet>
</bullets>
</property>
...
</properties>
Run Code Online (Sandbox Code Playgroud)
这是对如何查询xml以从中提取值的一瞥:
INSERT
INTO VProperty
( PropertyId,
Description
)
SELECT P.value('@propertyid', 'INT'),
NULL -- extract all the bullet text values into a single string
FROM @xml.nodes('/properties/property')
Run Code Online (Sandbox Code Playgroud)
在此示例中,我希望能够从xml中提取信息,因此最终结果如下:
PropertyId Description
1234 'nice garden\r\nit smells a bit\r\nbody under the patio
Run Code Online (Sandbox Code Playgroud)
在纯sql / xml中这是否可行?还是在我进入SQL领域之前我需要对xml进行一些预处理?
任何帮助表示赞赏(一如既往)。
我想使用XSL-FO来编写PDF.但在我看来,Java和这些文档的组合之间并没有真正的集成,就像添加/编辑对象(如表,图像等)到文档然后要求生成相应的XML一样.这方面有什么进展我不知道吗?
神秘主义.
我使用XSLT接收参考地址.
<a href="{element/url}"/>
Run Code Online (Sandbox Code Playgroud)
在XML中,我有:
<element>
<url>www.mysite.ru</url>
</element>
Run Code Online (Sandbox Code Playgroud)
因此,我在页面上收到:
<a href="www.currentsite.ru/cursection/cursubsection/www.mysite.ru"/>
Run Code Online (Sandbox Code Playgroud)
也就是说:在开头有一个当前站点的地址(我们现在所在的当前段的地址),然后有一个对外部站点的引用.
metatag BASE可能有任何问题吗?
真是个麻烦?
我的XSL源文档看起来像这样
<Topology>
<Environment>
<Id>test</Id>
<Machines>
<Machine>
<Id>machine1</Id>
<modules>
<module>m1</module>
<module>m2</module>
</modules>
</Machine>
</Machines>
</Environment>
<Environment>
<Id>production</Id>
<Machines>
<Machine>
<Id>machine1</Id>
<modules>
<module>m1</module>
<module>m2</module>
</modules>
</Machine>
<Machine>
<Id>machine2</Id>
<modules>
<module>m3</module>
<module>m4</module>
</modules>
</Machine>
</Machines>
</Environment>
</Topology>
Run Code Online (Sandbox Code Playgroud)
我想为每台机器创建一个结果文档,因此我使用以下样式表给出modelDir作为result-documents的路径作为参数.
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" name="myXML" doctype-system="http://java.sun.com/dtd/properties.dtd"/>
<xsl:template match="/">
<xsl:for-each-group select="/Topology/Environment/Machines/Machine" group-by="Id">
<xsl:variable name="machine" select="Id"/>
<xsl:variable name="filename" select="concat($modelDir,$machine,'.xml')" />
<xsl:message terminate="no">Writing machine description to <xsl:value-of select="$filename"/></xsl:message>
<xsl:result-document href="$filename" format="myXML">
<xsl:variable name="currentMachine" select="Id"/>
<xsl:for-each select="current-group()/LogicalHosts/LogicalHost">
<xsl:variable name="environment" select="normalize-space(../../../../Id)"/>
<xsl:message terminate="no">Module <xsl:value-of select="."/> for <xsl:value-of select="$environment"/></xsl:message>
</xsl:for-each> …Run Code Online (Sandbox Code Playgroud) 我正在使用文本输出方法.我需要忽略模板中的所有空格.
<xsl:template ...>
text
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
我收到输出"文本",但我只需要"文本".
谢谢.
我是StackOverflow的新用户,因此,如果我无意违反了任何论坛规则,请原谅我。
我正在从Cognos获取XML文档输出,我希望将其用作Crystal报表的输入。但是,Crystal Report所需的XML格式与Cognos输出的XML格式不同。
我正在尝试使用XSLT转换输入XML文档(Cognos),以获取Crystal所需的XML。
设置了上下文之后,下面是来自Cognos的Input XML:
<?xml version="1.0"?>
<dataset>
<metadata>
<item Name="EmpId" />
<item Name="EmpName" />
<item Name="DeptName" />
</metadata>
<data>
<rows>
<row>
<value>1</value>
<value>John</value>
<value>Finance</value>
</row>
<row>
<value>2</value>
<value>Peter</value>
<value>Admin</value>
</row>
</rows>
</data>
Run Code Online (Sandbox Code Playgroud)
Crystal Report所需的XML格式:
<?xml version="1.0"?>
<dataset>
<row>
<EmpId>1</EmpId>
<EmpName>John</EmpName>
<DeptName>Finance</DeptName>
</row>
<row>
<EmpId>2</EmpId>
<EmpName>Peter</EmpName>
<DeptName>Admin</DeptName>
</row>
</dataset>
Run Code Online (Sandbox Code Playgroud)
我在XSLT下方编写了所需的转换:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<dataset>
<xsl:for-each select="./dataset/data/rows/row">
<row>
<xsl:for-each select="/dataset/metadata/item">
<xsl:element name="{@Name}">
<xsl:for-each select="/dataset/data/rows/row/value">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</row>
</xsl:for-each>
</dataset>
</xsl:template> …Run Code Online (Sandbox Code Playgroud)