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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Use of before and after string (3) Sticky Topic
-> - How do I substitute element ty... (1)
-> + How does one add working days ... (4)
-> - Help, I have existing XLT and... (1)
-> + Need help on XSLT issue - (2)
-> + EDI to XML Conversion (7)
-> - XML To JSON Conversion using X... (1)
-> + Formatting Paragraphs to same ... (2)
-> - Grouping of records (1)
-> + Problems with xsd 1.1 (4)
-> + XML to HL7 mapping (3)
-> + XSLT 3 and Iterate (2)
-> + XSL-FO to PDF preview (3)
-> + java.lang.RuntimeException: Er... (2)
-> + Create Acroforms with Stylus X... (2)
-> + How to change XSLT parameter s... (3)
-> + how to change format of the da... (2)
-> + Search "Next 8 Results " doesn... (2)
-> - Support for Git (1)
-> + newbee (8)
-- [1-20] [21-40] [41-60] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
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.

   
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.