English 中文(简体)
我能否利用一个旁边,获得一个阵列项目的价值?
原标题:Using a for-each, can I get the value of an array item?

我对荷兰广播公司说得很新,因此,或许我关于“每个工程”如何不正确的概念。 我的各位正在从供应的ur中gra取XML文件中的每一件物品。 这符合预期。 我似乎无法看到的是,如何从各个阵列中取出与各自Xml文件有关的卢尔,并将它与该项目的原始财产混为一谈。 这是可能的吗? 在“WHAT_GOES_HERE”的标号上,我还要补充什么?

参见XSL2.0。

    <xsl:variable name="array" as="element()*">
        <item>https://www.example.com/_resources/data/blogs.xml</item> <!--item 1-->
        <item>https://www.example.com/_resources/data/blogs2.xml</item> <!--item 2--> 
    </xsl:variable>

    <xsl:for-each select="$array/document(.)/items/item">
       <item>
           <xsl:attribute name="href" select="concat(WHAT_GOES_HERE?,@href)"/>
       </item>
     </xsl:for-each>

这里的一个例子是XML。

    <items>
<item href="/news-and-events/news/2024-02-amplify-stem-course-based-undergraduate-research-experience.aspx" dsn="blogs">
      <homehero>true</homehero>
      <pubDate>02/19/2024</pubDate>
      <title>Example TItle</title>
      <description>Example</description>
      <highlights/>
      <author>Author Name</author>
      <hero-image>
        <img src="" alt=""/>
      </hero-image>
      <image>
        <img src="/_assets/images/news/2024/jinjie-square.JPG" alt="Four women look at computers in a lab"/>
      </image>
      <tags>
        <tag>lab</tag>
      </tags>
    <searchtags>lab</searchtags>
    </item>
</items>

最后,我想的是:

select="concat(https://www.example.com/_resources/data/blogs.xml ,@href)"
select="concat( https://www.example.com/_resources/data/blogs2.xml ,@href)"

我如何从那里获得这些价值观?

问题回答

我认为你需要做:

<xsl:for-each select="$array">
    <xsl:variable name="array-item" select="." />
    <xsl:for-each select="document(.)/items/item">
       <item>
           <xsl:attribute name="href" select="concat($array-item, @href)"/>
       </item>
    </xsl:for-each>
</xsl:for-each>

或更宽泛地说:

<xsl:for-each select="$array">
    <xsl:variable name="array-item" select="." />
    <xsl:for-each select="document($array-item)/items/item">
       <item href="{$array-item}{@href}"/>
    </xsl:for-each>
</xsl:for-each>

但结果对我来说并不重要。





相关问题
When test hanging in an infinite loop

I m tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here s the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> ...

quick xslt for-each question

Let s say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</...

XSLT Transform XML with Namespaces

I m trying to transform some XML into HTML using XSLT. Problem: I can t get it to work. Can someone tell me what I m doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/...

XSLT output to HTML

In my XSLT file, I have the following: <input type="button" value= <xsl:value-of select="name">> It s an error as it violates XML rule. What I actually want is having a value from an ...

Mangling IDs and References to IDs in XML

I m trying to compose xml elements into each other, and the problem I am having is when there s the same IDs. Basically what I need to do is mangle all the IDs in an xml file, as well as the ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签