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]

RE: Xpath newbie question


The match patterns of your template rules are mutually exclusive so it
shouldn't matter what order they are in. Ordering only matters if you have
two rules with the same priority that match the same node. In such a case
you should allocate explicit priorities to the rules using the priority
attribute.

You've made your match patterns quite unnecessarily complicated. For example
<xsl:template
> match="//command/documentCommand/*/entityIdentification">

can be simplified to
<xsl:template match="entityIdentification">

which would save the XSLT processor work.

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Eric Smith
> Sent: 13 September 2001 14:35
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Xpath newbie question
>
>
> Forgive me for allowing myself the luxury of asking what is probably a
> basic question, when perhaps I should be digging into the
> documentation to find the answer.
>
> I am unable to match all the xml data that I need to match in a single
> XSL instance.
>
> Relevant section of XML:
>
> <as2:envelope
> xmlns:as2="http://www.uc-council.org/smp/schemas/as2";
> xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg";
> xmlns:simpl-eb="http://www.uc-council.org/smp/schemas/simpl-eb
> " xmlns:msg="http://www.uc-council.org/smp/schemas/msg";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="http://www.uc-council.org/smp/schemas/as2
> Envelope.xsd" communicationVersion="1.0">
> 	<msg:body>
> 		<transaction>
> 			<entityIdentification>
>
> <uniqueCreatorIdentification>_1_uniqueCreatorIdentification_</
uniqueCreatorIdentification>
> 				<contentOwner>
> 					<gln>4134_gln_7002</gln>
> 				</contentOwner>
> 			</entityIdentification>
> 			<command>
> 				<documentCommand>
> 					<documentCommandHeader
> type="ADD">
> 						<entityIdentification>
>
> <uniqueCreatorIdentification>_2_uniqueCreatorIdentification_</
uniqueCreatorIdentification>
> 							<contentOwner>
>
> <gln>41344_gln_002</gln>
> 							</contentOwner>
> 						</entityIdentification>
> 					</documentCommandHeader>
> 					<documentCommandOperand>
> 						<fmcg:item
> creationDate="2001-06-28T12:13:14" documentStatus="ORIGINAL"
> contentVersion="1.0" documentStructureVersion="1.0"
> lastUpdateDate="2001-06-28">
>
> <fmcg:itemInformation>
>
> <paymentTerms type="BASIC_(NET)"
> eventType="ANTICIPATED_DELIVERY_DATE">
>
> 	<proximoCutOffDay>23</proximoCutOffDay>
>
> 	<discountPayment discountType="Preferential">
>
> 		<discountDescription>
>
> 			<description language="EN">
>
> 				<text>Preferential Customers</text>
>
> 			</description>
>
> 		</discountDescription>
>
> 		<date>2001-06-28</date>
>
> 	</discountPayment>
>
> 	<installmentDue>
>
> 		<percentageOfPaymentDue>12</percentageOfPaymentDue>
>
> 		<timePeriodDue type="DAYS">8</timePeriodDue>
>
> 	</installmentDue>
>
> 	<netPayment>
>
> 		<dayOfMonthDue>23</dayOfMonthDue>
>
> 	</netPayment>
>
> </paymentTerms>
>
> <allowanceCharge type="ALLOWANCE_GLOBAL"
> allowanceOrChargeType="ALLOWANCE"
> effectiveDateType="EFFECTIVE_DATE" sequenceNumber="1"
> settlementType="BILL_BACK">
>
> 	<priceBracketList>
>
> 		<bracketIdentifier>
> <snip>
>
> Here is the XSL with the "Discount" Template at the top of the file.
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> version='1.0' xmlns:fo="http://www.w3.org/1999/XSL/Format";
> xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg"; >
>
>
> <!-- Discount Rule now at the top -->
> <xsl:template
> match="//fmcg:itemInformation/paymentTerms/discountPayment/dis
> countDescription/description/text">
> <fo:block>
> Discount: <xsl:apply-templates/>
> </fo:block>
> </xsl:template>
> <xsl:template
> match="//command/documentCommand/*/entityIdentification">
>   <fo:block>Document Produced by: <xsl:value-of
> select="uniqueCreatorIdentification"/> </fo:block>
> </xsl:template>
>
> <xsl:template match="//fmcg:itemInformation/paymentTerms">
>   <fo:block>
>     Payment Terms: <xsl:value-of select="@type"/> based on
> <xsl:value-of select="proximoCutOffDay"/> days from
> <xsl:value-of select="@eventType"/>
>   </fo:block>
> </xsl:template>
>
> <xsl:template match="//installmentDue">
>   <fo:block>
>   Percentage of Payment due: <xsl:apply-templates
> select="percentageOfPaymentDue"/>
>   </fo:block>
> </xsl:template>
>
> <!-- alternatively Discount Rule could be here -->
> </xsl:stylesheet>
>
>
> The result of the XSL above is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> 				_1_uniqueCreatorIdentification_
> 					4134_gln_7002
> 						<fo:block
> xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>Document
> Produced by: _2_uniqueCreatorIdentification_</fo:block>
>
> 	23
>
> 				<fo:block
> xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>
> Discount: Preferential Customers</fo:block>
>
> 		2001-06-28
>
> 		12
>
> 		8
>
> <snip>
>
> However if the Discount Rule is at the bottom (or even
> deleted), then the
> output ibecomes:
>
> <?xml version="1.0" encoding="UTF-8"?>
> 				_1_uniqueCreatorIdentification_
> 					4134_gln_7002
> 						<fo:block
> xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>Document
> Produced by: _2_uniqueCreatorIdentification_</fo:block>
>
> <fo:block
> xmlns:fmcg="http://www.uc-council.org/smp/schemas/fmcg";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>
>     Payment Terms: BASIC_(NET) based on  23 days from
> ANTICIPATED_DELIVERY_DATE</fo:block>
>
> 			The entity ID here
>
> 		1234
>
> 		123.12
>
> 		24
>
> 		4
>
> 		98
> <snip>
>
>
> So with the "Discount"  template at the bottom, it has no
> effect and with it at
> the top it works fine but prevents the "Payment Terms" template from
> having any effect.
>
> How do I have all Templates matching at the same time?
>
> Thank you
> ---
> Eric Smith
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 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]