Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaration in XSLT

Status
Not open for further replies.

Smeat

Programmer
Mar 27, 2004
193
GB
HI

Can anyone tell me how to have my xslt file include <?xml version="1.0" culture="utf-8"?> in the output xml file as it's not included in the source document received from a third party?

The following is my xslt file:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="<xsl:eek:utput indent="yes"/>

<xsl:template match="/">
<Vehicles>
<xsl:apply-templates />
</Vehicles>
</xsl:template>

<xsl:template match="Vehicle">
<Vehicle>
<DealerID><xsl:value-of select="VsDealerRefNum" /></DealerID>
<Style></Style>
<Make><xsl:value-of select="Make" /></Make>
<Model><xsl:value-of select="Model" /></Model>
<Derivative><xsl:value-of select="Range" /></Derivative>
<NumGears></NumGears>
<NumCylinders></NumCylinders>
<BodyType></BodyType>
<FuelType><xsl:value-of select="Fuel" /></FuelType>
<NumDoors></NumDoors>
<NumSeats></NumSeats>
<GearBoxType><xsl:value-of select="Transmission" /></GearBoxType>
<InsuranceGroup><xsl:value-of select="InsuranceGroup" /></InsuranceGroup>
<SellingPrice><xsl:value-of select="RetailPrice" /></SellingPrice>
<Mileage><xsl:value-of select="Mileage" /></Mileage>
<CC><xsl:value-of select="EngineCC" /></CC>
<Registration><xsl:value-of select="Registration" /></Registration>
<VinNo></VinNo>
<Notes><xsl:value-of select="ShortDescription" /></Notes>
<Options>
<xsl:apply-templates select="Options" />
</Options>
<SerialEquipment></SerialEquipment>
<Images>
<xsl:apply-templates select="Images" />
</Images>
<VehicleImportID></VehicleImportID>
</Vehicle>
</xsl:template>

<xsl:template match="Options">
<xsl:for-each select="Option">
<Option>
<OptionCode><xsl:value-of select="Code" /></OptionCode>
<OptionDescription><xsl:value-of select="Description" /></OptionDescription>
<IsAssigned>1</IsAssigned>
</Option>
</xsl:for-each>
</xsl:template>

<xsl:template match="Images">
<xsl:for-each select="Image">
<Image>
<ImageID></ImageID>
<ImageData><xsl:value-of select="Fullsize" /></ImageData>
<IsPrimaryImage></IsPrimaryImage>
</Image>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Thanks for any help.

Smeat
 
see:

-or-


Try:
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:output indent="yes"/>

    <xsl:template match="/">
        [b]<xsl:processing-instruction name="xml">version="1.0" culture="utf-8"</xsl:processing-instruction>[/b]
        <Vehicles>
            <xsl:apply-templates />
        </Vehicles>
    </xsl:template>

    <xsl:template match="Vehicle">
        <Vehicle>
...



Visit My Site
PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Cube

Adding this to the xslt file didn't seem to alter the output though it did give me a hint as to where to look.

Adding the following to my code gave the required results:

//Create the ouput stream
XmlTextWriter writer = new XmlTextWriter(XMLTargetFileName, null);

writer.WriteProcessingInstruction("xml", "version=" + '"' + "1.0" + '"' + " encoding=" + '"' + "utf-8" + '"');

Thanks very much for your help.

Smeat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top