OVH Cloud OVH Cloud

Probleme de HTML de XML et de XSLT

1 réponse
Avatar
Manu
Bonjour,

Peut on conserver le code HTML contenu dans un XML qui est transformé via un
XSLT en un autre HTML ?

Par exemple, j'utilise un XmlTextWriter pour faire un XML simple contenant
peu d'information. Ensuite je le passe dans un XSLT pour en faire HTML.

Dim xmlTW As New System.Xml.XmlTextWriter(strFileXmlTmp,
System.Text.UnicodeEncoding.UTF8)
With xmlTW
.Formatting = Xml.Formatting.Indented
.Indentation = 3
.WriteStartDocument()
.WriteStartElement("root")
.WriteStartElement("voiture")
.WriteString("Ma <b>belle</b> voiture rouge.")
.WriteEndElement()
.WriteEndElement()
.WriteEndDocument()
.Flush()
.Close()
End With

Dim strFileHtmTmp As String = "c:\essai.htm")
Dim xslTran As New System.Xml.Xsl.XslTransform

xslTran.Load("C:\Transform.xslt")
xslTran.Transform(strFileXmlTmp, strFileHtmTmp, Nothing)

Source du C:\Transform.xslt

<?xml version="1.0" encoding="Windows-1252" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="iso-8859-15"
media-type="text/html" indent="yes" />
<xsl:template match="root">
<xsl:value-of select="voiture" />
</xsl:template>
</xsl:stylesheet>

Mais ça sort le code html de "Ma belle voiture" :(
Comment avoir Belle en gras ?

Manu

1 réponse

Avatar
Manu
Résolu. voir microsoft.public.fr.dotnet

"Manu" a écrit dans le message de news:
41f4053e$0$26207$
Bonjour,

Peut on conserver le code HTML contenu dans un XML qui est transformé via
un XSLT en un autre HTML ?

Par exemple, j'utilise un XmlTextWriter pour faire un XML simple contenant
peu d'information. Ensuite je le passe dans un XSLT pour en faire HTML.

Dim xmlTW As New System.Xml.XmlTextWriter(strFileXmlTmp,
System.Text.UnicodeEncoding.UTF8)
With xmlTW
.Formatting = Xml.Formatting.Indented
.Indentation = 3
.WriteStartDocument()
.WriteStartElement("root")
.WriteStartElement("voiture")
.WriteString("Ma <b>belle</b> voiture rouge.")
.WriteEndElement()
.WriteEndElement()
.WriteEndDocument()
.Flush()
.Close()
End With

Dim strFileHtmTmp As String = "c:essai.htm")
Dim xslTran As New System.Xml.Xsl.XslTransform

xslTran.Load("C:Transform.xslt")
xslTran.Transform(strFileXmlTmp, strFileHtmTmp, Nothing)

Source du C:Transform.xslt

<?xml version="1.0" encoding="Windows-1252" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="iso-8859-15"
media-type="text/html" indent="yes" />
<xsl:template match="root">
<xsl:value-of select="voiture" />
</xsl:template>
</xsl:stylesheet>

Mais ça sort le code html de "Ma belle voiture" :(
Comment avoir Belle en gras ?

Manu