[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: copy from one xml to another

Subject: Re: copy from one xml to another
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Mon, 22 Jul 2002 21:38:14 +0200
junitreport xml
Hello Erik,

you need three things:

1. Accessing the second file via document().
2. Accessing the correct Testcase via position().
3. A recursive template for accessing the last substring of the name of the Action.


<xsl:variable name="testcases" select="document('the-other-file')/Workflow/Testcase"/>

<xsl:template match="testcase">
  <xsl:copy>
    <xsl:copy-of select="@time"/>
    <xsl:attribute name="@name">
      <xsl:variable name="pos" select="position()"/>
      <xsl:call-template name="substring-after-last">
        <xsl:with-param name="string" select="$testcases[$pos]/Action"/>
      </xsl:call-template>
    </xsl:attribute>
  </xsl:copy>
</xsl:template>

<xsl:template name="substring-after-last">
<xsl:param name="string" select="''"/>
<xsl:param name="delimiter" select="."/>
<xsl:choose>
<xsl:when test="contains($string, $delimiter)">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="string" select="substring-after($string, $delimiter)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


Regards,

Joerg

Erik Stunkat wrote:
Hello,

We use JunitReport to generate xml testresults. For this case we have one
main class which gets data from a xml file. The output looks like this:

<testsuites>
 <testcase name="testGeneric" time="1.391"></testcase>

 <testcase name="testGeneric" time="0.937"></testcase>
</testsuites>

instead of "testGeneric" should be some data from another file.


The data.xml holds this information:


<Workflow>
<TestCase>

<Action>com.poet.ess.qa.extendedtests.testclasses.company.CreateCompany</Action>
            <UserID>admin</UserID>
            <DataID>CPQ_EMEA</DataID>
</TestCase>
<TestCase>

<Action>com.poet.ess.qa.extendedtests.testclasses.company.CreateUser</Action>
            <UserID>admin</UserID>
            <DataID>EUCO_100</DataID>
</TestCase>
</Workflow>


I need to write a stylesheet which combines the first and the second one: (eg writes the information from <Action> into <testcase name="">>


<testcase name="CreateCompany" time="1.391"></testcase> <testcase name="CreateUser" time="1.391"></testcase>

The order is the same.

Any ideas?

Thanks!

erik Stunkat
POET Software


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.