Project

Profile

Help

Encoding

Added by Anonymous over 18 years ago

Legacy ID: #3870171 Legacy Poster: stepd (stepd)

Hi, I've got a problem with a XSL transformation. I want to transform a XML file which contains some character like "é". This is the XML file : <?xml version="1.0" encoding="ISO-8859-1"?> <inbound> <GraCptNumEx>ROEDE1009</GraCptNumEx> <Pickticket> <PktCtlNbr>97806</PktCtlNbr> <PktNbr>97806</PktNbr> <OrderType>CR</OrderType> <PickticketHeaderFields> <ManagingTerritory>LIF</ManagingTerritory> <ShipTo>101038</ShipTo> <ShipToName>Monsieur Jean BECKER</ShipToName> <ShipToAddr1>Quai de la République</ShipToAddr1> <ShipToAddr2>ARC EN CIEL</ShipToAddr2> <ShipToCity>ST QUAY PORTRIEUX</ShipToCity> <ShipToZip>22410</ShipToZip> <ShipToCountry>001</ShipToCountry> <CustomerPONumber>17 THEO</CustomerPONumber> <OrderDate>2006-01-13T00:00:00+01:00</OrderDate> <ScheduleDeliveryDate>2006-01-13T00:00:00+01:00</ScheduleDeliveryDate> <InventoryShortageFlag></InventoryShortageFlag> <SpeclInstrCode1></SpeclInstrCode1> <CollectFreight>M</CollectFreight> <Related>1</Related> <CODFunds>A</CODFunds> <FTSRNbr>470.03</FTSRNbr> <PortOfLoading></PortOfLoading> <PortOfDischarge></PortOfDischarge> <TMSPurchaseOrderFlag>Y</TMSPurchaseOrderFlag> <DesigModeCode>M</DesigModeCode> <ShipToCnty>101038</ShipToCnty> </PickticketHeaderFields> <ListOfHdrInstructions> <PickticketHdrInstruction> <SpclInstrNbr>1</SpclInstrNbr> <SpclInstrType>03</SpclInstrType> <SpclInstrCode>01</SpclInstrCode> <PickticketInstrFields> <SpclInstrDesc>02 96 70 47 79</SpclInstrDesc> </PickticketInstrFields> </PickticketHdrInstruction> <PickticketHdrInstruction> <SpclInstrNbr>2</SpclInstrNbr> <SpclInstrType>03</SpclInstrType> <SpclInstrCode>01</SpclInstrCode> <PickticketInstrFields> <SpclInstrDesc>LIVRAISON IMPERATIVE LE 15 SEPTEMBRE</SpclInstrDesc> </PickticketInstrFields> </PickticketHdrInstruction> </ListOfHdrInstructions> <ListOfPickticketDetails> <PickticketDetail> <PktLineNbr>1</PktLineNbr> <SKU> <SKUDefinition> <SizeDesc>BT5S6</SizeDesc> </SKUDefinition> </SKU> <SubSKUFields> <BatchNumber>FRANCE</BatchNumber> </SubSKUFields> <PickticketDetailFields> <OrigOrderQty>5.00</OrigOrderQty> <OrigPktQty>5.00</OrigPktQty> <OriginalOrderLineNumber>1</OriginalOrderLineNumber> <RefField1>C06</RefField1> </PickticketDetailFields> </PickticketDetail> </ListOfPickticketDetails> </Pickticket> </inbound> And this is the XSL file : <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"> <!--Transformation du fichier .PKT (ordres de livraison) au format XML en provenance de chez Roederer--> <xsl:import href="communs.xsl"/> <xsl:import href="PKMS.xsl"/> <xsl:output method="xml" encoding="ISO-8859-1" omit-xml-declaration="yes" name="XMLFile" indent="yes"/> <xsl:template match="OrderDate"> <!--ajout d'une balie avec la date courante et avec l'heure courante (PktGenerationDate) après la balise OrderDate--> <xsl:element name="{name()}"> <xsl:apply-templates select="* | text() | @"/> </xsl:element> <xsl:text>&#10;&#32;&#32;&#32;&#32;</xsl:text> <xsl:element name="PktGenerationDate"> <xsl:call-template name="Date_PKMS"/> </xsl:element> </xsl:template> <xsl:template match="@"> <xsl:copy/> </xsl:template> <xsl:template match=""> <xsl:element name="{name()}"> <xsl:apply-templates select=" | text() | @*"/> </xsl:element> </xsl:template> </xsl:stylesheet> But the XML file which results of this transformation is encoded in UTF-8 and the "é" becomes a "é". This is the XML file in result : <?xml version="1.0" encoding="UTF-8"?><inbound> <GraCptNumEx>ROEDE1009</GraCptNumEx> <Pickticket> <PktCtlNbr>97806</PktCtlNbr> <PktNbr>97806</PktNbr> <OrderType>CR</OrderType> <PickticketHeaderFields> <ManagingTerritory>LIF</ManagingTerritory> <ShipTo>101038</ShipTo> <ShipToName>Monsieur Jean BECKER</ShipToName> <ShipToAddr1>Quai de la République</ShipToAddr1> <ShipToAddr2>ARC EN CIEL</ShipToAddr2> <ShipToCity>ST QUAY PORTRIEUX</ShipToCity> <ShipToZip>22410</ShipToZip> <ShipToCountry>001</ShipToCountry> <CustomerPONumber>17 THEO</CustomerPONumber> <OrderDate>2006-01-13T00:00:00+01:00</OrderDate> <PktGenerationDate>2006-08-16T17:49:16+01:00</PktGenerationDate> <ScheduleDeliveryDate>2006-01-13T00:00:00+01:00</ScheduleDeliveryDate> <InventoryShortageFlag/> <SpeclInstrCode1/> <CollectFreight>M</CollectFreight> <Related>1</Related> <CODFunds>A</CODFunds> <FTSRNbr>470.03</FTSRNbr> <PortOfLoading/> <PortOfDischarge/> <TMSPurchaseOrderFlag>Y</TMSPurchaseOrderFlag> <DesigModeCode>M</DesigModeCode> <ShipToCnty>101038</ShipToCnty> </PickticketHeaderFields> <ListOfHdrInstructions> <PickticketHdrInstruction> <SpclInstrNbr>1</SpclInstrNbr> <SpclInstrType>03</SpclInstrType> <SpclInstrCode>01</SpclInstrCode> <PickticketInstrFields> <SpclInstrDesc>02 96 70 47 79</SpclInstrDesc> </PickticketInstrFields> </PickticketHdrInstruction> <PickticketHdrInstruction> <SpclInstrNbr>2</SpclInstrNbr> <SpclInstrType>03</SpclInstrType> <SpclInstrCode>01</SpclInstrCode> <PickticketInstrFields> <SpclInstrDesc>LIVRAISON IMPERATIVE LE 15 SEPTEMBRE</SpclInstrDesc> </PickticketInstrFields> </PickticketHdrInstruction> </ListOfHdrInstructions> <ListOfPickticketDetails> <PickticketDetail> <PktLineNbr>1</PktLineNbr> <SKU> <SKUDefinition> <SizeDesc>BT5S6</SizeDesc> </SKUDefinition> </SKU> <SubSKUFields> <BatchNumber>FRANCE</BatchNumber> </SubSKUFields> <PickticketDetailFields> <OrigOrderQty>5.00</OrigOrderQty> <OrigPktQty>5.00</OrigPktQty> <OriginalOrderLineNumber>1</OriginalOrderLineNumber> <RefField1>C06</RefField1> </PickticketDetailFields> </PickticketDetail> </ListOfPickticketDetails> </Pickticket> </inbound> Please to help me because i really don't know how to resolve this problem


Replies (2)

RE: Encoding - Added by Anonymous over 18 years ago

Legacy ID: #3870196 Legacy Poster: Michael Kay (mhkay)

If you specify xsl:output encoding="iso-8859-1" then it doesn't make sense to also specify omit-xml-declaration="yes", since anyone reading a file with no XML declaration is obliged to assume that the encoding is UTF-8. However, I'm at a loss to explain why the output file you show is in UTF-8 when you asked for iso-8859-1, and has an XML declaration when you didn't ask for one. How did you run the transformation? Which version of Saxon? Aha! I've just noticed your xsl:output declaration contains name="XMLFile". That means it won't be used by default. So your xsl:output declaration is being ignored, which explains the format you are getting. Incidentally, the UTF representation of e acute only looks like "é" if you display it using software that doesn't know it's UTF-8. If you display it using software that understands UTF-8, as you should, then it looks like e acute.

RE: Encoding - Added by Anonymous over 18 years ago

Legacy ID: #3871077 Legacy Poster: stepd (stepd)

Ok, i've done the modifications and it's good. Thank you very much. Stéphane.

    (1-2/2)

    Please register to reply