This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: XPath Question.



I got it. It is something like

	<xsl:variable name="temp">
		<xsl:call-templates name="print_order" />
	</xsl:variable>

	<xsl:if test="contains(temp, '99')>
		<xsl:text>*99</xsl:text>
	</xsl:if>

	<xsl:template name="print_order">
		<xsl:for-each "/Customer/Order">
		<xsl:choose>
			<xsl:when test="OrderId=1001">
			</xsl:when>
			<xsl:when test="OrderId=1002">
			</xsl:when>
			<xsl:when test="OrderId=1003">
			</xsl:when>
			<xsl:when test="OrderId=1004">
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>*99</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
		</xsl:for-each>
	</xsl:template>
	
	-- Do you guys think of any easier way of doing this.


--Thanks
Raj..

> -----Original Message-----
> From:	Avula, Raj 
> Sent:	Friday, December 21, 2001 10:52 AM
> To:	'xsl-list@lists.mulberrytech.com'
> Subject:	RE: [xsl] XPath Question.
> 
> Hi Joerg,
> 	Thanks for the answer. But is there any easier way for doing this.
> Can I avoid having another xml file for doing this.
> 
> 
> 
> --Raj..
> 
> > -----Original Message-----
> > From:	Joerg Heinicke [SMTP:joerg.heinicke@gmx.de]
> > Sent:	Thursday, December 20, 2001 6:47 PM
> > To:	xsl-list@lists.mulberrytech.com
> > Subject:	Re: [xsl] XPath Question.
> > 
> > Hello Raj,
> > 
> > I created a mapping.xml with the follwing structure:
> > 
> > <mapping>
> >     <map OrderId="1001" mapped="1"/>
> >     <map OrderId="1002" mapped="2"/>
> >     <map OrderId="1003" mapped="3"/>
> >     <map OrderId="1004" mapped="4"/>
> > </mapping>
> > 
> > The I have the followng stylesheet:
> > 
> > <xsl:variable name="mapping" select="document('mapping.xml')/mapping"/>
> > 
> > <xsl:template match="/Customer">
> >     <xsl:text>OUT</xsl:text>
> >     <xsl:apply-templates select="Order[OrderId =
> $mapping/map/@OrderId]"/>
> >     <xsl:if test="Order[not(OrderId = $mapping/map/@OrderId)]">
> >         <xsl:text>*99</xsl:text>
> >     </xsl:if>
> > </xsl:template>
> > 
> > <xsl:template match="Order">
> >     <xsl:text>*</xsl:text>
> >     <xsl:value-of select="$mapping/map[@OrderId =
> > current()/OrderId]/@mapped"/>
> > </xsl:template>
> > 
> > The output: OUT*1*2*3*4*99.
> > 
> > Hope this helps,
> > 
> > Joerg
> > 
> > > Hi All,
> > > My XML file is some thing like this
> > >
> > > <Customer>
> > > <Order>
> > > <OrderId>1001</OrderId>
> > > </Order>
> > > <Order>
> > > <OrderId>1002/OrderId>
> > > </Order>
> > > <Order>
> > > <OrderId>1003</OrderId>
> > > </Order>
> > > <Order>
> > > <OrderId>1004</OrderId>
> > > </Order>
> > > <Order>
> > > <OrderId>1007</OrderId>
> > > </Order>
> > > <Order>
> > > <OrderId>1009</OrderId>
> > > </Order>
> > > </Customer>
> > >
> > > I have to print the output by mapping the codes
> > > 1001 - 1
> > > 1002 - 2
> > > 1003 - 3
> > > 1004 - 4
> > > If any OrderId is not in the above mapping table, I have to print 99.
> > >
> > > Output will be something like this:
> > > OUT*1*2*3*4*99*99
> > >
> > > My Problem here is if I have more than one OrderId codes that does not
> > match
> > > the mapping table, I have to print only one 99.
> > >
> > > Can any body help me, on How I can do that.
> > >
> > > Thanks,
> > > Raj..
> > 
> > 
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> > 
> 
> "MMS <firstam.com>" made the following
>  annotations on 12/21/01 10:53:20
> --------------------------------------------------------------------------
> ----
> "THIS E-MAIL MESSAGE AND ANY FILES TRANSMITTED HEREWITH, ARE INTENDED
> SOLELY FOR THE USE OF THE INDIVIDUAL(S) ADDRESSED AND MAY CONTAIN
> CONFIDENTIAL, PROPRIETARY OR PRIVILEGED INFORMATION.  IF YOU ARE NOT THE
> ADDRESSEE INDICATED IN THIS MESSAGE (OR RESPONSIBLE FOR DELIVERY OF THIS
> MESSAGE TO SUCH PERSON) YOU MAY NOT REVIEW, USE, DISCLOSE OR DISTRIBUTE
> THIS MESSAGE OR ANY FILES TRANSMITTED HEREWITH.  IF YOU RECEIVE THIS
> MESSAGE IN ERROR, PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE
> THIS MESSAGE AND ALL COPIES OF IT FROM YOUR SYSTEM."
> 
> ==========================================================================
> ====
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

"MMS <firstam.com>" made the following
 annotations on 12/21/01 14:53:39
------------------------------------------------------------------------------
"THIS E-MAIL MESSAGE AND ANY FILES TRANSMITTED HEREWITH, ARE INTENDED SOLELY FOR THE USE OF THE INDIVIDUAL(S) ADDRESSED AND MAY CONTAIN CONFIDENTIAL, PROPRIETARY OR PRIVILEGED INFORMATION.  IF YOU ARE NOT THE ADDRESSEE INDICATED IN THIS MESSAGE (OR RESPONSIBLE FOR DELIVERY OF THIS MESSAGE TO SUCH PERSON) YOU MAY NOT REVIEW, USE, DISCLOSE OR DISTRIBUTE THIS MESSAGE OR ANY FILES TRANSMITTED HEREWITH.  IF YOU RECEIVE THIS MESSAGE IN ERROR, PLEASE CONTACT THE SENDER BY REPLY E-MAIL AND DELETE THIS MESSAGE AND ALL COPIES OF IT FROM YOUR SYSTEM."

==============================================================================


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]