J'ai une transformation XSLT que j'utilise pour traiter un fichier XML, en l'insérant dans le corps de ma page aspx.xml déclaration non omise de la page
référence suivantes pour obtenir des informations de fond:
J'ai ce qui suit dans mon fichier xml:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
xmlns:myCustomStrings="urn:customStrings">
<xsl:output
method="xml" version="2.0"
media-type="text/html"
omit-xml-declaration="yes"
indent="yes"
/>...unrelated stuff left out here
est ici la sortie qui est relevent:
<div id="example" />
<?xml version="1.0" encoding="utf-8"?><div xmlns:myCustomStrings="urn:customStrings"><div id="imFormBody" class="imFormBody">
Ma question concerne la production, en particulier e <?xml version="1.0" encoding="utf-8"?>
qui est inclus dans la sortie de toute façon. Le problème est-il lié à la méthode personnalisée que j'ai utilisée? Si c'est le cas, je ne vois pas vraiment le besoin d'inclure la partie xml comme l'espace de noms est dans la balise div. Y a-t-il un moyen de faire en sorte que ces choses supplémentaires soient laissées de côté comme je le demandais?
transformer le code: oui, son laid, mais je Prototypage quelques trucs :)
public static string SmartNotePageFromTemplate(string patientVisitId, string followupType, bool copyPreviousNote)
{
// create custom object
CustomStrings customStrings = new CustomStrings();//specify class for use in XSLT
string noteXmlFile = ImSmartNotesConfig.GetSmartNotesXmlFile();//get xml data file name from config
string noteXslFile = ImSmartNotesConfig.GetSmartNotesXsltFile();// get xslt file name from config
string subXmlFile = "../SmartNotesXml/testData.xml";
string subCSSFile = "../CSS/testCSS.css";
string subJSFile = "../Js/testJS.js";
try
{
XsltSettings settings = new XsltSettings(true, true);// allow the document() in the xslt
XsltArgumentList xslArg = new XsltArgumentList();// create argument list for xslt
xslArg.AddParam("subXmlFile", "", subXmlFile);
xslArg.AddParam("subCSSFile", "", subCSSFile);
xslArg.AddParam("subJSFile", "", subJSFile);
//pass an instance of the custom object
xslArg.AddExtensionObject("urn:customStrings", customStrings);
XslCompiledTransform myXslt = new XslCompiledTransform(true);// we will use the compiled xslt processor
myXslt.Load(noteXslFile, settings, new XmlUrlResolver());// load the xslt in
StringWriter stWrite = new StringWriter();// create output writer
//myXslt.Transform(noteXmlFile, xslArg, stWrite);// transform
SmartNote.BL.SmartNoteLogic logic = new SmartNote.BL.SmartNoteLogic();
XmlDocument noteXml = logic.GetNewNoteXml(patientVisitId, followupType, copyPreviousNote);
myXslt.Transform(noteXml, xslArg, stWrite);// transform
return stWrite.ToString();// put the StringWriter as a string to the output- html page in this instance, as used in the .aspx.cs file
}
catch (Exception e)
{
throw e;
}
}
Votre code d'effectuer la transformation serait utile. –
(Par exemple, si vous finissez par charger votre sortie dans un XmlDocument et y faire un OuterXml, peu importe ce que dit votre déclaration omit-xml) –
Ajout du code de transformation –