473,698 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>OPE L</car_Short_Name> <car_Contracts> <CtoF_Contrac t
From_Date="" To_Date="">
<CtoF_Contract_ Type Type="Administr ator"/>
<Company_FID>Co mpany_204736</Company_FID>
</CtoF_Contract>
</car_Contracts>
<car_Contracts> <CtoF_Contrac t From_Date="" To_Date="">
<CtoF_Contract_ Type Type="Firm"/>
<Company_FID>Co mpany_204730</Company_FID>
</CtoF_Contract>
</car_Contracts>
</car>
</cars><Companies >
<Company>
<Company_FID>Co mpany_204730</Company_FID>
<Company_Legal_ Name From_Date="" To_Date="">
<Company_Name>H HLXC Management AG</Company_Name>
<Legal_Type>Unk nown</Legal_Type>
</Company_Legal_N ame>
<Legal_Domici le 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>Caill e</Street>
<City>Mexico city</City>
<ZIP_City>6301f f</ZIP_City>
<Country>Mexico </Country>
</Address>
<Site_Communica tion>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
<E-mail From_Date="" To_Date=""></E-mail>
</Site_Communicat ion>
</Site>
<Site Main="No">
<Address From_Date="" To_Date="">
<Street></Street>
<City></City>
<ZIP_City></ZIP_City>
<State></State>
<Country></Country>
</Address>
<Site_Communica tion>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
</Site_Communicat ion>
</Site>
</Company>
<Company>
<Company_FID>Co mpany_204736</Company_FID>
<Company_Legal_ Name From_Date="" To_Date="">
<Company_Name>H HC International, Ltd.</Company_Name>
<Legal_Type>Unk nown</Legal_Type>
</Company_Legal_N ame>
</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>Mexic o</domicile>
</cars>

any suggestions

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

<?xml version='1.0' ?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="Datasou rce/cars/car/car_Short_Name" >
<cars>
<xsl:value-of select="."/>
</cars>
</xsl:for-each>
<xsl:for-each
select="Datasou rce/cars/car/car_Contracts/CtoF_Contract/Company_FID">
<administrato r>
<xsl:if test=". = ../../../../../Companies/Company/Company_FID">
<xsl:value-of
select="../../../../../Companies/Company/Company_Legal_N ame/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>OPE L</car_Short_Name> <car_Contracts> <CtoF_Contrac t
From_Date="" To_Date="">
<CtoF_Contract_ Type Type="Administr ator"/>
<Company_FID>Co mpany_204736</Company_FID>
</CtoF_Contract>
</car_Contracts>
<car_Contracts> <CtoF_Contrac t From_Date="" To_Date="">
<CtoF_Contract_ Type Type="Firm"/>
<Company_FID>Co mpany_204730</Company_FID>
</CtoF_Contract>
</car_Contracts>
</car>
</cars><Companies >
<Company>
<Company_FID>Co mpany_204730</Company_FID>
<Company_Legal_ Name From_Date="" To_Date="">
<Company_Name>H HLXC Management AG</Company_Name>
<Legal_Type>Unk nown</Legal_Type>
</Company_Legal_N ame>
<Legal_Domici le 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>Caill e</Street>
<City>Mexico city</City>
<ZIP_City>6301f f</ZIP_City>
<Country>Mexico </Country>
</Address>
<Site_Communica tion>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
<E-mail From_Date="" To_Date=""></E-mail>
</Site_Communicat ion>
</Site>
<Site Main="No">
<Address From_Date="" To_Date="">
<Street></Street>
<City></City>
<ZIP_City></ZIP_City>
<State></State>
<Country></Country>
</Address>
<Site_Communica tion>
<Phone From_Date="" To_Date=""></Phone>
<Fax From_Date="" To_Date=""></Fax>
</Site_Communicat ion>
</Site>
</Company>
<Company>
<Company_FID>Co mpany_204736</Company_FID>
<Company_Legal_ Name From_Date="" To_Date="">
<Company_Name>H HC International, Ltd.</Company_Name>
<Legal_Type>Unk nown</Legal_Type>
</Company_Legal_N ame>
</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>Mexic o</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="$contra ct/CtoF_Contract/CtoF_Contract_T ype/@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="$compan y/Company_Legal_N ame/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:valu e-of select="$compan y/Company_Legal_N ame/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

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

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

Jun 9 '06 #3
ina

Andy Dingley <di*****@codesm iths.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="$contra ct/CtoF_Contract/CtoF_Contract_T ype/@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="$compan y/Company_Legal_N ame/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:valu e-of select="$compan y/Company_Legal_N ame/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

<domicile><xsl: value-of select="$compan y/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*****@codesm iths.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="$contra ct/CtoF_Contract/CtoF_Contract_T ype/@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="$compan y/Company_Legal_N ame/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:valu e-of select="$compan y/Company_Legal_N ame/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

<domicile><xsl: value-of select="$compan y/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*****@codesm iths.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="$contra ct/CtoF_Contract/CtoF_Contract_T ype/@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="$compan y/Company_Legal_N ame/Company_Name" /></administrator>
</xsl:when>

<xsl:when test="$contract-type = 'Firm'" >
<Firm><xsl:valu e-of select="$compan y/Company_Legal_N ame/Company_Name"
/></Firm>
</xsl:when>
</xsl:choose>

<domicile><xsl: value-of select="$compan y/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
6785
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 encoding used in the document, of the version of XML being used... Thanks.
16
6314
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 structure. There should then be a function to search that structure given the pointer, tag, and an optional attribute. I'm looking initially at only text data, no numbers, though eventuall there will be some binary data (CDATA?). Thanks.
12
3367
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 simply the title and link. If possible, how would I do this? Burnsy
4
1977
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 as it is in the HTML source. For example, let's say that the XML tag in my HTML source looks like this: <XML id="xmltest"> <TAG1>some text here for example</TAG1>
2
1737
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 tried <xsl:if test="ToutCompris = true"> and it does'nt work either
5
2333
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 Step</title> <author>Michael Halvorsen</author> <subject>Programming</subject>
4
2433
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" and include the extra html as shown below if the test passes. The rest of the code validates and so, I hope, works. What am I doing so very wrong here?
8
5653
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 seperator if it goes beyond 3 digits. i.e. the variable might be parsed as a string '1,324' or a number 56, depending on which XML file I have. I was trying to get rid of the comma seperator by breaking the string into two parts (that number will...
1
2019
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 (window.ActiveXObject) { var responseXml=new ActiveXObject("Microsoft.XMLDOM"); responseXml.async="false";
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.