WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

XML processing instruction / DTD mit xmlwrite

 

haraldStefan

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 05.05.2010, 10:24     Titel: XML processing instruction / DTD mit xmlwrite
  Antworten mit Zitat      
Hi,

für meine XML-Datei habe ich ein kleines Stylesheet geschrieben, welches mir den Inhalt der Datei schön darstellt.

Das Problem ist aber, dass mich xmlwrite() einfach nicht die Zeilen <!DOCTYPE myRoot SYSTEM "foo.dtd"> und <?xml-stylesheet href="style.css" type="text/css"?> einfügen lässt.

Minimalbeispiel:
Code:

function saveToXml
% Create a XML document.
docNode = com.mathworks.xml.XMLUtils.createDocument('myRoot');
   
    %proc = docNode.createProcessingInstruction('instruction');
    %docNode.insertBefore(proc, docNode.getFirstChild());
    %docNode.appendChild(docNode.createComment('this is a comment'));
    %docNode.PROCESSING_INSTRUCTION = 'xml-stylesheet type="a" href="foo"';

docRootNode = docNode.getDocumentElement;
   
% save aTest
tmp = docNode.createElement('aTest');
tmp.setAttribute('size', '1');
tmp.appendChild(docNode.createTextNode('content'));
docRootNode.appendChild(tmp);

    %docNode.appendChild(docNode.createComment('Automatically generated by structural analysis toolbox.'));

% Save the XML document.
%xmlFileName = uiputfile(sprintf('%s.xml', 'systemDescription'), 'Save XML file as');
xmlwrite('foo.xml',docNode);
edit('foo.xml');
end %function
 

liefert
Code:

<?xml version="1.0" encoding="utf-8"?>
<myRoot>
   <aTest size="1">content</aTest>
</myRoot>
 


Wie kann ich zwischen erster und zweiter Zeile etwas reinschreiben? Aussehen soll das ganze dann:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE myRoot SYSTEM "foo.dtd">
<?xml-stylesheet href="style.css" type="text/css"?>
<myRoot>
...


Folgende hab ich schon probiert, aber das geht leider nicht:
Code:
%proc = docNode.createProcessingInstruction('instruction');
docNode.insertBefore(proc, docNode.getFirstChild());

bzw.

docNode.PROCESSING_INSTRUCTION = 'xml-stylesheet type="a" href="foo"';


Hat jemand eine Idee?


haraldStefan

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 05.05.2010, 22:41     Titel: Berlin
  Antworten mit Zitat      
*pushing* hat wirklich keiner eine Idee?
Gruß
 
jacky9876

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 15.11.2012, 12:58     Titel: matlab insert style sheet information
  Antworten mit Zitat      
function saveToXml
% Create a XML document.
docNode = com.mathworks.xml.XMLUtils.createDocument('myRoot');

%proc = docNode.createProcessingInstruction('instruction');
%docNode.insertBefore(proc, docNode.getFirstChild());
%docNode.appendChild(docNode.createComment('this is a comment'));
%docNode.PROCESSING_INSTRUCTION = 'xml-stylesheet type="a" href="foo"';

docRootNode = docNode.getDocumentElement;

style = docNode.createProcessingInstruction('xml-stylesheet', 'type=text/xsl href=plausibility.xsl');
docNode.insertBefore(style, docRootNode);

% save aTest
tmp = docNode.createElement('aTest');
tmp.setAttribute('size', '1');
tmp.appendChild(docNode.createTextNode('content'));
docRootNode.appendChild(tmp);

%docNode.appendChild(docNode.createComment('Automatically generated by structural analysis toolbox.'));

% Save the XML document.
%xmlFileName = uiputfile(sprintf('%s.xml', 'systemDescription'), 'Save XML file as');
xmlwrite('foo.xml',docNode);
edit('foo.xml');
end %function
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2025 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.