XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Violeta DonevaSubject: XSLT problem
Author: Violeta Doneva
Date: 10 Aug 2006 09:54 AM
Hello,

I have this input file that I want to transform:

<definition name="fr.inria.test.clientServerComp" extends="fr.inria.test.rootType">
<component name="client" definition="fr.inria.test.client" />
<component name="more" definition="fr.inria.test.more" >
<component name="inMore">
<interface name="blabla" signature="olala"></interface>
<component name="inInMore-1">
<interface name="blabla" signature="olala"></interface>
</component>
<component name="inInMore-2">
<interface name="blabla" signature="olala"></interface>
</component>
</component>
<component name="inMore-second">
<interface name="blabla" signature="olala"></interface>
</component>
</component>
<component name="server" definition="fr.inria.test.server" />
<component name="inMore" definition="fr.inria.test.more"/>
</component>
<binding client="this.runnableItf" server="client.runnableItf" />
<binding client="client.print" server="server.print" />
</definition>


I have this additional xml file:
<fractal-deployment>

<real-host name="Belote">
<virtual-host name="VH2" type="jvm">
<execution-context name="EC2" >
<content>
<component-name>server</component-name>
</content>
</execution-context>
</virtual-host>
<ip>138.96.64.61</ip>
</real-host >

<real-host name="Parlote">
<virtual-host name="VH1" type="jvm">
<execution-context name="EC1" >
<content>
<component-name>client</component-name>
<component-name>inMore</component-name>
</content>
</execution-context>
</virtual-host>
</real-host>

</fractal-deployment>

The goal of the XSLT is to insert virtual-node element with attribute name and value of this attribute equal of the corresponding execution context, in the component elements. The result after my XSLT transformation is:

<definition name="fr.inria.test.clientServerComp" extends="fr.inria.test.rootType">
<component name="client" definition="fr.inria.test.client" >
<virtual-node name="EC1">
</component>
<component name="more" definition="fr.inria.test.more" >
<component name="inMore">
<interface name="blabla" signature="olala"></interface>
<component name="inInMore-1">
<interface name="blabla" signature="olala"></interface>
</component>
<component name="inInMore-2">
<interface name="blabla" signature="olala"></interface>
</component>
<virtual-node name="EC1">
</component>
<component name="inMore-second">
<interface name="blabla" signature="olala"></interface>
</component>
</component>
<component name="server" definition="fr.inria.test.server" />
<component name="inMore" definition="fr.inria.test.more"/>
<virtual-node name="EC2">
</component>
<binding client="this.runnableItf" server="client.runnableItf" />
<binding client="client.print" server="server.print" />
</definition>

That is what i managed to do with the folowing XSL :

<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">



<xsl:variable name="depl_file" select="document('../data/deployfractal.xml')"/>

<xsl:template match="node()|@*">

<xsl:copy>

<xsl:apply-templates select="node()|@*"/>

</xsl:copy>

</xsl:template>

<xsl:template match="//component">

<xsl:copy>

<xsl:apply-templates select="@* | node()"/>


<xsl:variable name="comp_name" select="$depl_file//real-host/virtual-host/execution-context/content/component-name/text()"/>

<xsl:if test="current()/@name=$comp_name">

<xsl:element name="virtual-node">

<xsl:attribute name="name">

<xsl:value-of select="$depl_file//real-host/virtual-host/execution-context[content/component-name/text() = current()/@name]/@name"/>

</xsl:attribute>

</xsl:element>

</xsl:if>

</xsl:copy>

</xsl:template>

</xsl:transform>



But the problem is that there is difference between the component inMore in more and the component inMore in server. So I want to reference the components in the deployment xml file like this :

<component-name>server/inMore</component-name>
<component-name>more/inMore</component-name>
<component-name>more/inMore/inInMore-2</component-name>

The problem is that I dont know how to modify the XSLT to do now the insertion of virtual-node-s correctly.
Do you have any suggestions?
One particular problem for me is that I dont know how to reference for example ONLY the second child component of the root element. "child::component[position()=2]" returns to me not only the component "more" but also the second component in it "inMore-second".

Thank you.

Violeta

Postnext
Minollo I.Subject: XSLT problem
Author: Minollo I.
Date: 10 Aug 2006 01:08 PM
Violeta,
what Stylus Studio version and build number are you running? (Help > About)

Posttop
James DurningSubject: XSLT problem
Author: James Durning
Date: 10 Aug 2006 03:16 PM
Please clarify which file is your 'deployment xml'

I am trying hard to see exactly which way you want to have your xml mapped, but it is still ambiguous to me.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.