English 中文(简体)
利用XSL申请从ID属地搬走拖车空间
原标题:Trying to remove trailing space from ID attribute using XSL apply-template
  • 时间:2011-11-22 16:39:48
  •  标签:
  • xml
  • xslt

这里是SL。 我正试图从单元q_DECISION_中删除。 NUMBER, and use it to establish both a data elements as well as an ID Depende. 但是,数据元件含有白天空间,因此,白天空间也在采集和生产:id=“23-7/16”

我试图利用正常空间,并翻译()但都没有这样做。

没有人提出建议?

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="html" encoding="UTF-8" 
             doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

 <xsl:template match="/">

  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>Untitled Document</title>

  </head>

  <body>
  <xsl:apply-templates select="Root"/>

  </body>
  </html>

 </xsl:template>

 <xsl:template match="q_DECISION_NUMBER">
  <h2 class="q_DECISION_NUMBER"><xsl:attribute name="id">d<xsl:apply-templates/>   
  </xsl:attribute><xsl:apply-templates/></h2>
  </xsl:template>

</xsl:stylesheet>

这里有一些带有典型数据的Xml样本,而不是整个XML来源:

<Root><DECISION><q_DECISION_NUMBER>1-1/1 </q_DECISION_NUMBER></DECISION>
<DECISION><q_DECISION_NUMBER>1-1/2 </q_DECISION_NUMBER></DECISION>
<DECISION><q_DECISION_NUMBER>1-1/3 </q_DECISION_NUMBER></DECISION>
</Root>

注 以上数据要素的空间。 这一白色空间正在由国际发展法属地取而代之,但是如果我们利用国际发展法作为超链接的目的地,它就没有工作。 如果我们寻找并拆除拖车空间,国际发展法会进行罚款。 这可能是简单的,但我可以说出。

最佳回答
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/1999/xhtml">
  <xsl:output method="html" encoding="UTF-8" 
              doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" 
              doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

  <xsl:template match="/">

    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Untitled Document</title>
      </head>

      <body>
        <xsl:apply-templates select="Root"/>
      </body>
    </html>

  </xsl:template>

  <xsl:template match="q_DECISION_NUMBER">
    <h2 class="q_DECISION_NUMBER" id="{concat( d , 
                                      translate(normalize-space(.),  / ,  - ))}">
      <xsl:apply-templates/>
    </h2>
  </xsl:template>

</xsl:stylesheet>

注:

  • xmlns="http://www.w3.org/1999/xhtml" on <xsl:stylesheet>: puts all elements in the output in the XHTML namespace
  • translate(...): attributes of type ID in XHTML are not allowed to contain / characters
问题回答

暂无回答




相关问题
how to represent it in dtd?

I have two element action and guid. guid is a required field when action is add. but when action is del it will not appear in file. How to represent this in dtd ?

.Net application configuration add xml-data

I need to add xml-content to my application configuration file. Is there a way to add it directly to the appSettings section or do I need to implement a configSection? Is it possible to add the xml ...

XStream serializing collections

I have a class structure that I would like to serialize with Xstream. The root class contains a collection of other objects (of varying types). I would like to only serialize part of the objects that ...

MS Word splits words in its XML format

I have a Word 2003 document saved as a XML in WordProcessingML format. It contains few placeholders which will be dynamically replaced by an appropriate content. But, the problem is that Word ...

Merging an XML file with a list of changes

I have two XML files that are generated by another application I have no control over. The first is a settings file, and the second is a list of changes that should be applied to the first. Main ...

How do I check if a node has no siblings?

I have a org.w3c.dom.Node object. I would like to see if it has any other siblings. Here s what I have tried: Node sibling = node.getNextSibling(); if(sibling == null) return true; else ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

热门标签