Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2008, 05:31 AM
Registered User
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default doubt in xslt

hi
i have a doubt
i have an xml input file ,it contains a container,in that container it contains different parameters ,from that i want to write code



xml code
<container>
<container:parametervalues>
<container:enum>parameter1</container:enum>
<container:value>data<container:value>
<container:enum>parameter2</container:enum>
<container:value></container:value>
<container:int>parameter3</container:int>
<container:value>3</container:value>
<container:boolean>parameter4</container:boolean>
<container:value>true</container:value>
</container:parametervalues>
</container>

like this it contains 4 containers with same parameters with same or different values

perl code
if($parameter1!='data')
{
if($parameter2='')
{
print error
}
if($parameter3='3')
{
print error
}
}

i wrote the xslt code like this but it not fetching the values properly

xslt code


<xsl:if test="DEF= '/container/parameter1'">
<xsl:if test="VALUE != 'data'">
<xsl:if test="DEF= '/container/parameter2'">
<xsl:if test="'VALUE' = ''">
error:the value is not configured
</xsl:if>
</xsl:if>
<xsl:if test="DEF= '/container/parameter3'">
<xsl:if test="'VALUE' = '3'"> error:the value is 3
</xsl:if>
</xsl:if>
</xsl:if>

now based on these codes i need in xslt
the problem is not fetching the values properly
i tried different methods but its not coming
plz reply as soon as possible
 
Old May 5th, 2008, 06:37 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't really understand what you are trying to achieve, why are you comparing values with strings of XPath? For instance DEF= '/container/parameter1'. Can you explain the business rules a bit more?

--

Joe (Microsoft MVP - XML)
 
Old May 5th, 2008, 07:05 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly, your XML isn't well-formed so I'm surprised you can process it at all. In <container:enum> you are using "container" as a namespace prefix, but you haven't declared it anywhere (I would expect to see xmlns:container="some....uri".)

Let's imagine you solve that by getting rid of the namespace, so it reads

<parametervalues>
<enum>parameter1</enum>
<value>data<value>

You can now find the value of parameter1 using the path expression

/container/parametervalues/*[.='parameter1']/following-sibling::value[1]

However, this is a very odd way to design your XML. Why not use

<parameter name="parameter1" type="enum" value="data"/>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 5th, 2008, 07:58 AM
Registered User
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cross post...
http://forums.devshed.com/xml-progra...lt-526501.html


http://forums.tizag.com/showthread.php?p=45543





Similar Threads
Thread Thread Starter Forum Replies Last Post
Doubt hamnapalakkal Crystal Reports 0 February 4th, 2008 12:27 AM
doubt in XSLT -- very urgent subbukns XSLT 1 May 21st, 2007 05:10 PM
doubt! kk_katepally ASP.NET 1.0 and 1.1 Basics 1 February 7th, 2006 01:58 PM
doubt in xslt rameshnarayan XSLT 2 August 31st, 2005 07:28 AM
doubt naveen J2EE 1 April 6th, 2004 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.