即每个< features我想查找每个功能 取决于并生成文本文件。例如,在下面的 文件中,我想找出功能A取决于A1和A2以及 功能B取决于B1和B2。并将其写入文本文件。 如何在XSLT中执行此操作?我知道我可以使用for-each循环通过''features'' 元素但是如何进行查找? 感谢您的帮助。 < feature name =" A"> < depends =" A1" /> < depends =" A2" /> < / feature> < feature name =" B"> < depends =" B1" /> < ; depends =" B2" /> < / feature> < features> < feature name =" A" /> < feature name =" B" /> < / features>Hi,I have a newbie XSLT question. I have the following xml, and I wouldlike tofind out the children of feature element in each ''features'' element.i.e. for each <featuresI would like to look up what each featuredepends on and gerenate a text file. For example, in the followingfile, I would like to find out feature A depends on A1 and A2 andfeature B depends on B1 and B2. And write that to a text file.How can I do that in XSLT? I know I can loop thru the ''features''element using "for-each" but how can I do the lookup ?Thanks for any help.<feature name="A"><depends ="A1"/><depends ="A2"/></feature><feature name="B"><depends ="B1"/><depends ="B2"/></feature><features><feature name="A"/><feature name="B"/></features>推荐答案 yi ***** @ gmail.com 写道: yi*****@gmail.com wrote: 如何在XSLT中执行此操作?我知道我可以使用for-each循环通过''features'' 元素但是如何进行查找呢?How can I do that in XSLT? I know I can loop thru the ''features''element using "for-each" but how can I do the lookup ? 你甚至没有展示过''featutes''元素。如果你知道xsl:for-each 为什么你不能使用一个xsl:for-each select =" feature"然后在里面那个 另一个xsl:for-each select ="取决于?You have not even shown a ''featutes'' element. If you know xsl:for-eachwhy can''t you use one xsl:for-each select="feature" and then inside thatanother xsl:for-each select="depends"? < depends =" A1" / > <depends ="A1"/> ^^^^^^^^^^^^^^^^ 这甚至不是XML。 - Martin Honnen http://JavaScript.FAQTs.com/ yi ***** @ gmail.com 写道: 我有一个新手XSLT题。我有以下xmlHi,I have a newbie XSLT question. I have the following xml 您的示例不是XML。我建议你重新设计它。 除此之外,你还没有向我们展示一切。你谈到 功能A取决于A1和A2,但你的数据中没有任何地方 说什么A1和A2是什么。 你几乎肯定不需要或不想循环通过任何东西。 在XSLT中,你想要的东西可以通过 模板更简单地完成。 但首先您必须拥有格式良好或有效的XML文档。 /// Peter - XML常见问题解答: http://xml.silmaril.ie ,我会Your example is not XML. I suggest you redesign it so that it is.Quite apart from that, you haven''t shown us everything. You talk aboutfeature A depending on A1 and A2, but nowhere in your data is thereanything to say what A1 and A2 are.You almost certainly don''t need or want to "loop" through anything.In XSLT, what you appear to want can be done much more simply withtemplates.But first you have to have a well-formed or valid XML document.///Peter--XML FAQ: http://xml.silmaril.ieand I would 喜欢 找出每个''features'元素中feature元素的子元素。 即每个< features我想查找每个功能 依赖并生成文本文件。例如,在下面的 文件中,我想找出功能A取决于A1和A2以及 功能B取决于B1和B2。并将其写入文本文件。 如何在XSLT中执行此操作?我知道我可以使用for-each循环通过''features'' 元素但是如何进行查找? 感谢您的帮助。 < feature name =" A"> < depends =" A1" /> < depends =" A2" /> < / feature> < feature name =" B"> < depends =" B1" /> < ; depends =" B2" /> < / feature> < features> < feature name =" A" /> < feature name =" B" /> < / features>like tofind out the children of feature element in each ''features'' element.i.e. for each <featuresI would like to look up what each featuredepends on and gerenate a text file. For example, in the followingfile, I would like to find out feature A depends on A1 and A2 andfeature B depends on B1 and B2. And write that to a text file.How can I do that in XSLT? I know I can loop thru the ''features''element using "for-each" but how can I do the lookup ?Thanks for any help.<feature name="A"> <depends ="A1"/> <depends ="A2"/></feature><feature name="B"> <depends ="B1"/> <depends ="B2"/></feature><features> <feature name="A"/> <feature name="B"/></features> Martin Honnen写道:Martin Honnen wrote: yi ***** @ gmail.com 写道: yi*****@gmail.com wrote: 如何在XSLT中执行此操作?我知道我可以使用for-each循环通过''features'' 元素但是如何进行查找呢? How can I do that in XSLT? I know I can loop thru the ''features'' element using "for-each" but how can I do the lookup ? 你甚至没有展示过''featutes''元素。如果你知道xsl:for-each 为什么你不能使用一个xsl:for-each select =" feature"然后在里面那个 另一个xsl:for-each select ="取决于?You have not even shown a ''featutes'' element. If you know xsl:for-eachwhy can''t you use one xsl:for-each select="feature" and then inside thatanother xsl:for-each select="depends"? < depends =" A1" / > <depends ="A1"/> ^^^^^^^^^^^^^^^^ 这甚至不是XML。 ^^^^^^^^^^^^^^^^This is not even XML. 这显然是个错误。他最可能的意思是: < feature name =" A"> < depends name =" A1" /> < depends name =" A2" /> < / feature> < feature name = B> < depends name =" B1" /> < depends name =" B2" /> < / feature> < features> < feature name =" A" /> < feature name =" B" /> < / features>This is obviously a mistake. What he most probably meant is:<feature name="A"><depends name="A1"/><depends name="A2"/></feature><feature name="B"><depends name="B1"/><depends name="B2"/></feature><features><feature name="A"/><feature name="B"/></features> 这篇关于XSLT问题:如何在XSLT中查找另一个标记的子项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 14:19