Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XSLT在XML文档中查找标记内的链接_Xml_Xslt - Fatal编程技术网

XSLT在XML文档中查找标记内的链接

XSLT在XML文档中查找标记内的链接,xml,xslt,Xml,Xslt,有没有一种方法可以让xsl样式表在xml文档的标记中出现链接时识别并将其转换为工作链接 例如: <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="guys.xsl"?> <people> <person> <name>Guy 1</name> <bio>Guy 1 i

有没有一种方法可以让xsl样式表在xml文档的标记中出现链接时识别并将其转换为工作链接

例如:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="guys.xsl"?>

<people>
   <person>
      <name>Guy 1</name>
      <bio>Guy 1 is a guy.</bio>
   </person>

   <person>
      <name>Guy 2</name>
      <bio>Guy 2 is from <a href="http://www.example.com">somewhere</a>.</bio>
   </person>
</people>

男1
第一个人是个男人。
盖伊2
第二个家伙来自美国。

Guy 1的个人简历应该以常规文本显示,Guy 2的个人简历中应该有一个工作链接。

如果您试图以html格式显示,这将立即生效:

<html>
<body>
  <xsl:for-each select="people/person">
     <div>
       <xsl:value-of select="name"/>
     </div>
     <div>
       <xsl:copy-of select="bio"/>
     </div>
  </xsl:for-each>
</body>
</html>

编辑:将的值更改为的副本。见本讨论:

如果您试图以html格式显示此内容,此操作将立即生效:

<html>
<body>
  <xsl:for-each select="people/person">
     <div>
       <xsl:value-of select="name"/>
     </div>
     <div>
       <xsl:copy-of select="bio"/>
     </div>
  </xsl:for-each>
</body>
</html>

编辑:将的值更改为的副本。见本讨论:

有没有一种方法可以使用xsl 样式表识别链接的时间 显示在xml中的标记内 文档并将其转换为工作文档 链接

是的。这种转变

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/*">
   <table border="1">
     <xsl:apply-templates/>
   </table>
 </xsl:template>

 <xsl:template match="person">
   <tr>
     <xsl:apply-templates/>
   </tr>
 </xsl:template>

 <xsl:template match="person/*">
   <td><xsl:copy-of select="node()"/></td>
 </xsl:template>
</xsl:stylesheet>
<table border="1">
   <tr>
      <td>Guy 1</td>
      <td>Guy 1 is a guy.</td>
   </tr>

   <tr>
      <td>Guy 2</td>
      <td>Guy 2 is from <a href="http://www.example.com">somewhere</a>.</td>
   </tr>
</table>

应用于提供的XML文档时:

<people>
   <person>
      <name>Guy 1</name>
      <bio>Guy 1 is a guy.</bio>
   </person>

   <person>
      <name>Guy 2</name>
      <bio>Guy 2 is from <a href="http://www.example.com">somewhere</a>.</bio>
   </person>
</people>

男1
第一个人是个男人。
盖伊2
第二个家伙来自美国。
产生想要的结果

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/*">
   <table border="1">
     <xsl:apply-templates/>
   </table>
 </xsl:template>

 <xsl:template match="person">
   <tr>
     <xsl:apply-templates/>
   </tr>
 </xsl:template>

 <xsl:template match="person/*">
   <td><xsl:copy-of select="node()"/></td>
 </xsl:template>
</xsl:stylesheet>
<table border="1">
   <tr>
      <td>Guy 1</td>
      <td>Guy 1 is a guy.</td>
   </tr>

   <tr>
      <td>Guy 2</td>
      <td>Guy 2 is from <a href="http://www.example.com">somewhere</a>.</td>
   </tr>
</table>

男1
第一个人是个男人。
盖伊2
第二个家伙来自美国。
有没有一种方法可以使用xsl 样式表识别链接的时间 显示在xml中的标记内 文档并将其转换为工作文档 链接

是的。这种转变

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/*">
   <table border="1">
     <xsl:apply-templates/>
   </table>
 </xsl:template>

 <xsl:template match="person">
   <tr>
     <xsl:apply-templates/>
   </tr>
 </xsl:template>

 <xsl:template match="person/*">
   <td><xsl:copy-of select="node()"/></td>
 </xsl:template>
</xsl:stylesheet>
<table border="1">
   <tr>
      <td>Guy 1</td>
      <td>Guy 1 is a guy.</td>
   </tr>

   <tr>
      <td>Guy 2</td>
      <td>Guy 2 is from <a href="http://www.example.com">somewhere</a>.</td>
   </tr>
</table>

应用于提供的XML文档时:

<people>
   <person>
      <name>Guy 1</name>
      <bio>Guy 1 is a guy.</bio>
   </person>

   <person>
      <name>Guy 2</name>
      <bio>Guy 2 is from <a href="http://www.example.com">somewhere</a>.</bio>
   </person>
</people>

男1
第一个人是个男人。
盖伊2
第二个家伙来自美国。
产生想要的结果

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/*">
   <table border="1">
     <xsl:apply-templates/>
   </table>
 </xsl:template>

 <xsl:template match="person">
   <tr>
     <xsl:apply-templates/>
   </tr>
 </xsl:template>

 <xsl:template match="person/*">
   <td><xsl:copy-of select="node()"/></td>
 </xsl:template>
</xsl:stylesheet>
<table border="1">
   <tr>
      <td>Guy 1</td>
      <td>Guy 1 is a guy.</td>
   </tr>

   <tr>
      <td>Guy 2</td>
      <td>Guy 2 is from <a href="http://www.example.com">somewhere</a>.</td>
   </tr>
</table>

男1
第一个人是个男人。
盖伊2
第二个家伙来自美国。

是的。如果您发布“guys.xsl”,我们可以告诉您为什么没有呈现链接。另外,请告诉我们xsl输出的最终目的地——它是指向浏览器还是其他呈现机制?好问题(+1)。请参阅我的答案以获得完整的解决方案。是的,是的。如果您发布“guys.xsl”,我们可以告诉您为什么没有呈现链接。另外,请告诉我们xsl输出的最终目的地——它是指向浏览器还是其他呈现机制?好问题(+1)。请参阅我的答案以获得完整的解决方案。完美。这正是我想要的。太好了。这正是我想要的。