Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2781 connectés 

  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  transformation xslt en c# (resultat dans un string)

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

transformation xslt en c# (resultat dans un string)

n°1333828
southcg
Posté le 28-03-2006 à 16:56:58  profilanswer
 

Bonjour je voudrais faire une transformation xslt en c#. J'arrive à effectuer cette transformation lorsque
le resultat est un fichier, mais lorsque je souhaite que le resultat soit de type string ca ne marche pas. Quelqu'un aurait il une idée?
voici le code

 

   string sauv = string.Empty;
    try
            {
                //Create a new XslTransform object.
                XslTransform xslt = new XslTransform();

 

               //Load the stylesheet.
                xslt.Load(Server.MapPath("../Index/index.xsl" ));
           

 


                //Create a new XPathDocument and load the XML data to be transformed.
                XmlDocument xp = new XmlDocument();
                xp.Load(Server.MapPath("../Index/index.xml" ));

 

               //Create an XmlTextWriter which outputs to the console.
                XmlTextWriter writer = new XmlTextWriter(html, null);
               
               
                //Transform the data and send the output to the console.
                xslt.Transform(xp, null, writer, null);
                writer.Close();//la transformation xslt fonctionne
               
                XmlReader filexml = xslt.Transform(xp, new XsltArgumentList(), new XmlUrlResolver());
               
                int i=0;
                while (!filexml.EOF)    
                {
                    sauv +=  ++i + " " + filexml.ReadOuterXml();
                    filexml.Read();
                }//sauv est vide
            }
            catch(Exception e1)
            {
                toto.InnerHtml =  e1.ToString();
            }

mood
Publicité
Posté le 28-03-2006 à 16:56:58  profilanswer
 

n°1333835
southcg
Posté le 28-03-2006 à 17:00:27  profilanswer
 

source xml :
<?xml version="1.0" encoding="utf-8"?>
<FichierXmlCollection xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fichiers>
<fichier>
<Nom>06X001.xml</Nom>
<Etat>redacteur</Etat>
<NomCreateur>CG67cyrille.hurstel</NomCreateur>
<DateCreation>2006/03/02</DateCreation>
</fichier>
<fichier>
<Nom>Copie (2) de 06X001.xml</Nom>
<Etat>redacteur</Etat>
<NomCreateur>CG67cyrille.hurstel</NomCreateur>
<DateCreation>2006/03/02</DateCreation>
</fichier>
<fichier>
<Nom>Copie (2) de PCR00501.xml</Nom>
<Etat>redacteur</Etat>
<NomCreateur>CG67yannick.lang</NomCreateur>
<DateCreation>2006/03/01</DateCreation>
</fichier>
<fichier>
<Nom>PCR00501.xml</Nom>
<Etat>redacteur</Etat>
<NomCreateur>yannick.lang</NomCreateur>
<DateCreation>2006/04/01</DateCreation>
</fichier>
<fichier>
<Nom>PCR00501.xml</Nom>
<Etat>redacteur</Etat>
<NomCreateur>CG67yannick.lang</NomCreateur>
<DateCreation>2006/03/01</DateCreation>
</fichier>
 
</fichiers>
</FichierXmlCollection>
 
source xsl :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" version="4.0" encoding="ISO-8859-1"/>
<xsl:template match="fichiers">
<xsl:apply-templates select="fichier">
<xsl:sort select="DateCreation"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="fichier">
&lt;div&gt;
&lt;span class="text"&gt;<xsl:value-of select="Nom"/>&lt;/span&gt;
&lt;span class="text"&gt;<xsl:value-of select="Etat"/>&lt;/span&gt;
&lt;span class="text"&gt;<xsl:value-of select="NomCreateur"/>&lt;/span&gt;
&lt;span class="text"&gt;<xsl:value-of select="DateCreation"/>&lt;/span&gt;
&lt;/div&gt;
</xsl:template>
</xsl:stylesheet>


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  transformation xslt en c# (resultat dans un string)

 

Sujets relatifs
XSLT+PHP sous windows possible ?[xslt][PHP][xsltproc]utiliser plusieur feuille de style XSL
[XSLT] generate-id() amelioré ?[Oracle 9i]Export résultat de requête SQL vers fichier XML?
XSLT qui ne fait rienRésultat fonction PHP différente
[Resolu] Recherche d'occurences dans une variable String[xslt] Découpage d'une chaine de caractères
Ecrire le résultat d'un script python dans un fichier textesélection un objet grace à un string
Plus de sujets relatifs à : transformation xslt en c# (resultat dans un string)


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)