xlst template for simulink xml parsing
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Luca Ferro
am 9 Mär. 2023
Kommentiert: Luca Ferro
am 13 Mär. 2023
i'm trying to export a simulink webview (without the use of the report generator toolbox).
My thought was to convert the .slx file to .xml in matlab, then in python parse the .xml to .html.
this is my matlab code:
load_system('scSam') %scSam is the .slx model, mind it's just a dummy with some random blocks thrown in
save_system('xmltest', 'model_xml.xml','ExportToXML', true);
once i have the xml file, i parse it in python:
import lxml.html
from lxml import etree
xslt_doc = etree.parse("test-xslt.xslt") %this is the xslt template i'm using
xslt_transformer = etree.XSLT(xslt_doc)
source_doc = etree.parse("xmltest.xml")
output_doc = xslt_transformer(source_doc)
output_doc.write("htmltest.html", pretty_print=True)
my issue is that i cannot find or write a decent xlst stylesheet able to actually reproduce the simulink file.
I'm glad to hear some suggestions from you. Maybe this approach is overcomplicating things, or mabe there is a public simulink xlst file i don't know about. Or mabe this jsut can't be done withtout the toolbox
Edit: i'm thinking of doing the latter conversion part in Java, is it a good idea? i'm not really familiar with it other than the basics but i know it has some good xml libraries
0 Kommentare
Akzeptierte Antwort
Sakshay
am 13 Mär. 2023
Hello Luca,
As per my understanding, you want to export a Simulink model to web view. You are able to convert a Simulink model to XML file, but are having trouble converting XML to HTML file.
You can use the MATLAB function "xlst" for the second part of your workflow. "xlst" function is used to transform an XML document using XLST engine. For example, to convert a file "info.xml", using the stylesheet "info.xsl", to the file "info.html" and launch the resulting HTML file in the MATLAB Web Browser, an example code for the same would look like:
xslt('info.xml', 'info.xsl', 'info.html', '-web')
For more information on "xlst" function, you can refer to the following documentation:
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Create Model Web Views finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!