[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSL Transformation help


xml bcd
Just write a rule that causes these elements not to be copied:

<xsl:template match="WorkstationID|SalespersonID|TransactionNumber"/>

Michael Kay
Software AG
home: Michael.H.Kay@n...
work: Michael.Kay@s... 

> -----Original Message-----
> From: Vanam, Ravindar [mailto:Ravindar.Vanam@n...]
> Sent: 17 April 2002 17:21
> To: XMl Mailing List (E-mail)
> Subject:  XSL Transformation help
> 
> 
> Hi,
> 
> I have the following XML and XSL files. I need to transform 
> the XML doc to another doc given below with XSL. I am getting 
> the output but with some extra unwanted XML tags. Can 
> somebody throw some light on how to transform the XML 
> document to get the exact output that I want.
> 
> xmlfile.xml
> ----------------
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- Check - Only User hand keyed the data-->
> <TenderAuthorizationRequest>
> 	<RetailStoreID>000427</RetailStoreID>
> 	<WorkstationID>01</WorkstationID>
> 	<SalespersonID>12345</SalespersonID>
> 	<TransactionNumber>12345</TransactionNumber>
> </TenderAuthorizationRequest>
> 
> xslfile.xsl
> ------------------
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
> <xsl:output method="xml" indent="yes" encoding="UTF-8"/> 
> 	<!-- Match the root node -->
> 	<xsl:template match="*|@*|text()">
> 		<xsl:copy>
> 			<xsl:apply-templates select="*|@*|text()"/>
> 		</xsl:copy>
> 	</xsl:template>
> 
> 	<xsl:template match="RetailStoreID">
> 		<element name="DestinationSystemID" type="bcd" 
> totalDigits="6" whiteSpace="0" value="0"/>
> 		<element name="SourceSystemID" type="bcd" 
> totalDigits="6" value="{//RetailStoreID}"/>
> 		<element name="FunctionCode" type="bcd" 
> totalDigits="2" value="0"/>
> 		<element name="StatusCode" type="bcd" 
> totalDigits="3" value="0"/>
> 		<elementBlock name="MessageLength" type="bcd" 
> totalDigits="4" />
> 		<element name="SequenceBufferNumber" type="bcd" 
> totalDigits="8" value="023F0000"/>
> 		<element name="SystemID" type="bcd" 
> totalDigits="4" value="8862"/>
> 		<element name="RetailStoreID" type="bcd" 
> totalDigits="6" value="{//RetailStoreID}"/>
> 	</xsl:template>
> </xsl:stylesheet>
> 
> outputxsml.xml
> -------------------------
> <?xml version="1.0"?>
> <TenderAuthorizationRequest>
> 	<version-record major="0" minor="1" revision="0" build="1000">
> 	</version-record>
> 	<element name="DestinationSystemID" type="bcd" 
> totalDigits="6" whiteSpace="0" value="0"/>
> 	<element name="SourceSystemID" type="bcd" 
> totalDigits="6" value="000427"/>
> 	<element name="FunctionCode" type="bcd" totalDigits="2" 
> value="0"/>
> 	<element name="StatusCode" type="bcd" totalDigits="3" 
> value="0"/>
> 	<elementBlock name="MessageLength" type="bcd" totalDigits="4"/>
> 	<element name="SequenceBufferNumber" type="bcd" 
> totalDigits="8" value="023F0000"/>
> 	<element name="SystemID" type="bcd" totalDigits="4" 
> value="8862"/>
> 	<element name="RetailStoreID" type="bcd" 
> totalDigits="6" value="000427"/>
> 	<WorkstationID>01</WorkstationID>
> 	<SalespersonID>12345</SalespersonID>
> 	<TransactionNumber>12345</TransactionNumber>
> </TenderAuthorizationRequest>
> 
> requiredoutputxml.xml
> ------------------------------------
> <?xml version="1.0"?>
> <TenderAuthorizationRequest>
> 	<version-record major="0" minor="1" revision="0" build="1000">
> 	</version-record>
> 	<element name="DestinationSystemID" type="bcd" 
> totalDigits="6" whiteSpace="0" value="0"/>
> 	<element name="SourceSystemID" type="bcd" 
> totalDigits="6" value="000427"/>
> 	<element name="FunctionCode" type="bcd" totalDigits="2" 
> value="0"/>
> 	<element name="StatusCode" type="bcd" totalDigits="3" 
> value="0"/>
> 	<elementBlock name="MessageLength" type="bcd" totalDigits="4"/>
> 	<element name="SequenceBufferNumber" type="bcd" 
> totalDigits="8" value="023F0000"/>
> 	<element name="SystemID" type="bcd" totalDigits="4" 
> value="8862"/>
> 	<element name="RetailStoreID" type="bcd" 
> totalDigits="6" value="000427"/>
> </TenderAuthorizationRequest>
> 
> Problem:
> I do not want the following tags in the outputxml.xml file
> 
> 	<WorkstationID>01</WorkstationID>
> 	<SalespersonID>12345</SalespersonID>
> 	<TransactionNumber>12345</TransactionNumber>
> 
> 
> Thanks,
> Ravi
> 
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>
> 

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.