English 中文(简体)
• 如何在XSL风格表上使用继纤维,只选择XML档案中的作者?
原标题:How can i use following-sibling on a XSL stylesheet to select only the authors in a XML file?

我有一份XML文件,显示作者的出版,其中含有某些条款或假日。 与此类似:

<dblp>
<inproceedings key="aaa" mdate="bbb">
<author>author1</author>
<author>author2</author>
<author>author3</author>
<author>author4</author>
<title>Title of pubblications</title>
<pages>12345</pages>
<year>12345</year>
<crossref>sometext</crossref>
<booktitle>sometext</booktitle>
<url>sometext</url>
<ee>sometext</ee>
</inproceedings>

<article key="aaa" mdate="bbb">
<author>author1</author>
<author>author2</author>
<title>Title of pubblications</title>
<pages>12345</pages>
<year>12345</year>
<crossref>sometext</crossref>
<booktitle>sometext</booktitle>
<url>sometext</url>
<ee>sometext</ee>
</article>

</dblp>

I have to create an XSL stylesheet to trasform this file in a .dot file that shows only the collaboration with the authors from all the pubblications. Like this:

author1--author2;
author1--author3;
author1--author4;
author2--author3;
author2--author4;
author3--author4;

这是第一次出版,第二次发行:

author1--author2;

I have to write all the connection by the author with no repeats. How can i do this? I write something to display all the connection but i must delete the repeats. Can i solve using following-sibling?

<xsl:variable name="papers" select="dblp/*"/>
        <xsl:for-each select="$papers">
            <xsl:variable name="autori" select="author"/>
            <xsl:variable name="autori2" select="author"/>
            <xsl:for-each select="$autori">
                <xsl:variable name="i" select="node()"/>
                    <xsl:for-each select="$autori2">
                        <xsl:if test=".!=$i">
                            <xsl:value-of select="$i"/><xsl:text>--</xsl:text><xsl:value-of select="."/><xsl:text>;</xsl:text>
                        </xsl:if>
                    </xsl:for-each><xsl:text>&#xa;</xsl:text>
            </xsl:for-each>
        </xsl:for-each>

Thanks for the answers!

最佳回答
<xsl:for-each select="author[position() != last()]">
  <xsl:variable name="a1" select="."/>
  <xsl:for-each select="following-sibling::author">
    <xsl:value-of select="concat($a1,  -- , .,  ;&#10; )"/>
  </xsl:for-each>
</xsl:for-each>
问题回答

暂无回答




相关问题
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

热门标签