472,980 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,980 software developers and data experts.

small question about <xml:if>

ina
Hello guys,

My name is ina and I have a problem with a file xlst. I am newbie and
sorry for this question, probably must be very simple.

I have this xml file

<?xml version="1.0"?>
<Datasource>
<cars><car><car_Short_Name>OPEL</car_Short_Name><car_Contracts><CtoF_Contract
From_Date="" To_Date="">
<CtoF_Contract_Type Type="Administrator"/>
<Company_FID>Company_204736</Company_FID>
</CtoF_Contract>
</car_Contracts>
<car_Contracts><CtoF_Contract From_Date="" To_Date="">
<CtoF_Contract_Type Type="Firm"/>
<Company_FID>Company_204730</Company_FID>
</CtoF_Contract>
</car_Contracts>
</car>
</cars><Companies>
<Company>
<Company_FID>Company_204730</Company_FID>
<Company_Legal_Name From_Date="" To_Date="">
<Company_Name>HHLXC Management AG</Company_Name>
<Legal_Type>Unknown</Legal_Type>
</Company_Legal_Name>
<Legal_Domicile From_Date="" To_Date="">
<Country>CH</Country>
</Legal_Domicile>
<Web_Site From_Date="" To_Date="">www.company.com</Web_Site>
<Site Main="Yes">
<Address From_Date="" To_Date="">
<Street>Caille</Street>
<City>Mexico city</City>
<ZIP_City>6301ff</ZIP_City>
<Country>Mexico</Country>
</Address>
<Site_Communication>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
<E-mail From_Date="" To_Date=""></E-mail>
</Site_Communication>
</Site>
<Site Main="No">
<Address From_Date="" To_Date="">
<Street></Street>
<City></City>
<ZIP_City></ZIP_City>
<State></State>
<Country></Country>
</Address>
<Site_Communication>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
</Site_Communication>
</Site>
</Company>
<Company>
<Company_FID>Company_204736</Company_FID>
<Company_Legal_Name From_Date="" To_Date="">
<Company_Name>HHC International, Ltd.</Company_Name>
<Legal_Type>Unknown</Legal_Type>
</Company_Legal_Name>
</Company>
</Companies></Datasource>

and I am trying to use in xlts <xml:if> but with no success. I would
like to do it is to find the company information for each company ID in
car and type of contract.

I would like to have these results with xlts

<cars>
<car_name>OPEL></car_name>
<administrator>HHC International, Ltd</administrator>
<domicile></domicile>
<Firm>HHLXC Management AG</Firm>
<domicile>Mexico</domicile>
</cars>

any suggestions

Jun 9 '06 #1
5 1184
ina
this is the xlts:

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="Datasource/cars/car/car_Short_Name">
<cars>
<xsl:value-of select="."/>
</cars>
</xsl:for-each>
<xsl:for-each
select="Datasource/cars/car/car_Contracts/CtoF_Contract/Company_FID">
<administrator>
<xsl:if test=". = ../../../../../Companies/Company/Company_FID">
<xsl:value-of
select="../../../../../Companies/Company/Company_Legal_Name/Company_Name"/>
</xsl:if>
</administrator>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Ina
ina wrote:
Hello guys,

My name is ina and I have a problem with a file xlst. I am newbie and
sorry for this question, probably must be very simple.

I have this xml file

<?xml version="1.0"?>
<Datasource>
<cars><car><car_Short_Name>OPEL</car_Short_Name><car_Contracts><CtoF_Contract
From_Date="" To_Date="">
<CtoF_Contract_Type Type="Administrator"/>
<Company_FID>Company_204736</Company_FID>
</CtoF_Contract>
</car_Contracts>
<car_Contracts><CtoF_Contract From_Date="" To_Date="">
<CtoF_Contract_Type Type="Firm"/>
<Company_FID>Company_204730</Company_FID>
</CtoF_Contract>
</car_Contracts>
</car>
</cars><Companies>
<Company>
<Company_FID>Company_204730</Company_FID>
<Company_Legal_Name From_Date="" To_Date="">
<Company_Name>HHLXC Management AG</Company_Name>
<Legal_Type>Unknown</Legal_Type>
</Company_Legal_Name>
<Legal_Domicile From_Date="" To_Date="">
<Country>CH</Country>
</Legal_Domicile>
<Web_Site From_Date="" To_Date="">www.company.com</Web_Site>
<Site Main="Yes">
<Address From_Date="" To_Date="">
<Street>Caille</Street>
<City>Mexico city</City>
<ZIP_City>6301ff</ZIP_City>
<Country>Mexico</Country>
</Address>
<Site_Communication>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
<E-mail From_Date="" To_Date=""></E-mail>
</Site_Communication>
</Site>
<Site Main="No">
<Address From_Date="" To_Date="">
<Street></Street>
<City></City>
<ZIP_City></ZIP_City>
<State></State>
<Country></Country>
</Address>
<Site_Communication>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
</Site_Communication>
</Site>
</Company>
<Company>
<Company_FID>Company_204736</Company_FID>
<Company_Legal_Name From_Date="" To_Date="">
<Company_Name>HHC International, Ltd.</Company_Name>
<Legal_Type>Unknown</Legal_Type>
</Company_Legal_Name>
</Company>
</Companies></Datasource>

and I am trying to use in xlts <xml:if> but with no success. I would
like to do it is to find the company information for each company ID in
car and type of contract.

I would like to have these results with xlts

<cars>
<car_name>OPEL></car_name>
<administrator>HHC International, Ltd</administrator>
<domicile></domicile>
<Firm>HHLXC Management AG</Firm>
<domicile>Mexico</domicile>
</cars>

any suggestions


Jun 9 '06 #2
ina wrote:
like to do it is to find the company information for each company ID in
car and type of contract.


Try this. It's not great code, but it should be readable. Making it
better would need more information, particularly about error handling,
handling changes of address etc. It could get to be quite complex.

The XML schema is also less well-designed than it could be. Be generous
with container elements to wrap up related items, be careful with case,
be careful with plurals
<xsl:output method ="xml" indent="yes" />

<xsl:template match="/">

<cars>
<xsl:for-each select="/Datasource/cars/car">
<!--
You'd be better with a <car> container element here
<car>
-->
<car_name><xsl:value-of select="./car_Short_Name"
/></car_name>
<xsl:for-each select="./car_Contracts">
<xsl:variable name="contract" select="." />
<xsl:variable name="contract-type"
select="$contract/CtoF_Contract/CtoF_Contract_Type/@Type" />
<xsl:variable name="company"
select="/Datasource/Companies/Company [Company_FID =
$contract/CtoF_Contract/Company_FID] " />

<xsl:choose>
<xsl:when test="$contract-type = 'Administrator'" >
<administrator><xsl:value-of
select="$company/Company_Legal_Name/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:value-of select="$company/Company_Legal_Name/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

<domicile><xsl:value-of select="$company/Site [@Main='Yes']
/Address/Country" /></domicile>
</xsl:for-each>

<!-- </car> -->
</xsl:for-each>
</cars>
</xsl:template>

Jun 9 '06 #3
ina

Andy Dingley <di*****@codesmiths.com> wrote:
ina wrote:
like to do it is to find the company information for each company ID in
car and type of contract.


Try this. It's not great code, but it should be readable. Making it
better would need more information, particularly about error handling,
handling changes of address etc. It could get to be quite complex.

The XML schema is also less well-designed than it could be. Be generous
with container elements to wrap up related items, be careful with case,
be careful with plurals
<xsl:output method ="xml" indent="yes" />

<xsl:template match="/">

<cars>
<xsl:for-each select="/Datasource/cars/car">
<!--
You'd be better with a <car> container element here
<car>
-->
<car_name><xsl:value-of select="./car_Short_Name"
/></car_name>
<xsl:for-each select="./car_Contracts">
<xsl:variable name="contract" select="." />
<xsl:variable name="contract-type"
select="$contract/CtoF_Contract/CtoF_Contract_Type/@Type" />
<xsl:variable name="company"
select="/Datasource/Companies/Company [Company_FID =
$contract/CtoF_Contract/Company_FID] " />

<xsl:choose>
<xsl:when test="$contract-type = 'Administrator'" >
<administrator><xsl:value-of
select="$company/Company_Legal_Name/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:value-of select="$company/Company_Legal_Name/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

<domicile><xsl:value-of select="$company/Site [@Main='Yes']
/Address/Country" /></domicile>
</xsl:for-each>

<!-- </car> -->
</xsl:for-each>
</cars>
</xsl:template>


Jun 9 '06 #4
ina
Thanks Andy. It is a great help :D

I am newbie in XML and I do not know the grammar very well.
I will try it.
Thanks

Ina
Andy Dingley <di*****@codesmiths.com> wrote:
ina wrote:
like to do it is to find the company information for each company ID in
car and type of contract.


Try this. It's not great code, but it should be readable. Making it
better would need more information, particularly about error handling,
handling changes of address etc. It could get to be quite complex.

The XML schema is also less well-designed than it could be. Be generous
with container elements to wrap up related items, be careful with case,
be careful with plurals
<xsl:output method ="xml" indent="yes" />

<xsl:template match="/">

<cars>
<xsl:for-each select="/Datasource/cars/car">
<!--
You'd be better with a <car> container element here
<car>
-->
<car_name><xsl:value-of select="./car_Short_Name"
/></car_name>
<xsl:for-each select="./car_Contracts">
<xsl:variable name="contract" select="." />
<xsl:variable name="contract-type"
select="$contract/CtoF_Contract/CtoF_Contract_Type/@Type" />
<xsl:variable name="company"
select="/Datasource/Companies/Company [Company_FID =
$contract/CtoF_Contract/Company_FID] " />

<xsl:choose>
<xsl:when test="$contract-type = 'Administrator'" >
<administrator><xsl:value-of
select="$company/Company_Legal_Name/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:value-of select="$company/Company_Legal_Name/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

<domicile><xsl:value-of select="$company/Site [@Main='Yes']
/Address/Country" /></domicile>
</xsl:for-each>

<!-- </car> -->
</xsl:for-each>
</cars>
</xsl:template>


Jun 9 '06 #5
ina
Thanks Andy. It is a great help :D

I am newbie in XML and I do not know the grammar very well.
I will try it.
Thanks

Ina
Andy Dingley <di*****@codesmiths.com> wrote:
ina wrote:
like to do it is to find the company information for each company ID in
car and type of contract.


Try this. It's not great code, but it should be readable. Making it
better would need more information, particularly about error handling,
handling changes of address etc. It could get to be quite complex.

The XML schema is also less well-designed than it could be. Be generous
with container elements to wrap up related items, be careful with case,
be careful with plurals
<xsl:output method ="xml" indent="yes" />

<xsl:template match="/">

<cars>
<xsl:for-each select="/Datasource/cars/car">
<!--
You'd be better with a <car> container element here
<car>
-->
<car_name><xsl:value-of select="./car_Short_Name"
/></car_name>
<xsl:for-each select="./car_Contracts">
<xsl:variable name="contract" select="." />
<xsl:variable name="contract-type"
select="$contract/CtoF_Contract/CtoF_Contract_Type/@Type" />
<xsl:variable name="company"
select="/Datasource/Companies/Company [Company_FID =
$contract/CtoF_Contract/Company_FID] " />

<xsl:choose>
<xsl:when test="$contract-type = 'Administrator'" >
<administrator><xsl:value-of
select="$company/Company_Legal_Name/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:value-of select="$company/Company_Legal_Name/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

<domicile><xsl:value-of select="$company/Site [@Main='Yes']
/Address/Country" /></domicile>
</xsl:for-each>

<!-- </car> -->
</xsl:for-each>
</cars>
</xsl:template>


Jun 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: yzzzzz | last post by:
Hi, In which cases is the <?xml version="1.0" encoding="UTF-8"?> processing instruction required at the beginning of an XML document, for the document to be valid? e.g. does it depend on the...
16
by: Mike | last post by:
Does anyone know of a minimal/mini/tiny/small xml parser in c? I'm looking for something small that accepts a stream or string, builds a c structure, and then returns an opaque pointer to that...
12
by: bissatch | last post by:
Hi, Is it possible for me to store HTML tags inside XML nodes? I need some way to share news headlines. Because the headlines differ in their presentsation, it would be very difficult to store...
4
by: lidija | last post by:
Hi everybody, My problem is following: in the HTML source I have an <XML> tag, containing an XML document. I am trying to read this XML and save it, but I have problem saving it in the same form...
2
by: websls | last post by:
I tried to do this : <xsl:if test="ToutCompris"> some output </xsl:if> ToutCompris is a boolean element in my XML file My problem is the output is parse even when ToutCompris is false I...
5
by: Luke Vogel | last post by:
Hi all, Probably a really basic question, but I cant find an answer ... I have an xml file of books something like: <product> <isbn>0-735-61374-5</isbn> <title>Microsoft Visual Basic Step By...
4
by: mark4asp | last post by:
I'm getting a problem with this code and I think the offending linke is : <xsl:if test="$folder = 'Search'"> I want to test the value of the Folder element for a value of precisely "Search"...
8
by: Hoi Wong | last post by:
With the XSLT 1.0 engine that I was forced to use, I have to parse old XML scripts where the number (to be parsed and saved into $EPISODE_NUMBER_RAW) that I want to parse is written with a comma...
1
by: sumanmshan | last post by:
Hi everyone, This is my first post to this forum, hope I would get a reply quickly :-) Iam using loadXML(xmlString) and it is always returning "false". My code looks like this : if...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.