Maple Professionel
Maple Académique
Maple Edition Étudiant
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professionel
MapleSim Académique
Maple T.A. - Suite d'examens de classement
Maple T.A. MAA Placement Test Suite
Möbius - Didacticiels de mathématiques en ligne
Machine Design / Industrial Automation
Aéronautique
Ingénierie des véhicules
Robotics
Energie
System Simulation and Analysis
Model development for HIL
Modélisation du procédé pour la conception de systèmes de contrôle
Robotics/Motion Control/Mechatronics
Other Application Areas
Enseignement des mathématiques
Enseignement de l’ingénierie
Enseignement secondaire et supérieur (CPGE, BTS)
Tests et évaluations
Etudiants
Modélisation financière
Recherche opérationnelle
Calcul haute performance
Physique
Webinaires en direct
Webinaires enregistrés
Agenda des évènements
Forum MaplePrimes
Blog Maplesoft
Membres Maplesoft
Maple Ambassador Program
MapleCloud
Livres blancs techniques
Bulletin électronique
Livres Maple
Math Matters
Portail des applications
Galerie de modèles MapleSim
Cas d'Etudes Utilisateur
Exploring Engineering Fundamentals
Concepts d’enseignement avec Maple
Centre d’accueil utilisateur Maplesoft
Centre de ressources pour enseignants
Centre d’assistance aux étudiants
Programmatic Worksheet Access
This worksheet demonstrates some of the features of the Worksheet package. This package provides support for accessing Maple worksheets programmatically. As you read this worksheet, execute the commands in sequence.
restart:
Accessing the Worksheet Package
To use the Worksheet package, you must first issue the following call to the procedure with, which provides interactive access to procedures organized in packages.
with(Worksheet);
Importing a Worksheet As an XML Document
Maple worksheets are represented in Maple as XML documents. This makes it unnecessary to know the (undocumented) storage format for the Maple worksheet and allows you to use new and existing tools for manipulating XML document instances. (For details, see XMLTools.) To create an XML representation of a worksheet, use the ReadFile and FromString commands.
wname := cat(kernelopts(datadir), "/../examplesclassic/WorksheetPackage.mws"):
doc := ReadFile(wname):
Converting a Worksheet to Different Formats
Note that Maple worksheets can be imported into Maple in two different formats: -- "mw", this is the same format that is used by the Standard worksheet,
-- "maple8_xml", the format introduced in Maple 8.
Option `format` can be used to specify which XML representation to generate.
doc2 := ReadFile(wname, format = "maple8_xml"):
Display the worksheet you loaded by using the Display command.
# Display(doc);
# Display(doc2);
Use the Convert utility to convert worksheets in "mw" format to worksheets in "maple8_xml" format and back.
doc3 := Convert(doc, format="maple8_xml"):
evalb(doc2 = doc3);
l := XMLTools:-Compare(doc2, doc3);
if l <> [] then [op(l[1..-3], doc2), op(l[1..-3], doc3)] end if;
To convert a worksheet to ".mws" format, use the ToString command.
str := ToString(doc, format = "mws"):
Accessing a Worksheet By Using the XMLTools Package
Now that you have the worksheet exported as an XML document, you can use functions from the XMLTools package to access its subnodes.
XMLTools[FirstChild](doc);
XMLTools[SecondChild](doc);
XMLTools[AttributeTable](%);
XMLTools[ThirdChild](doc);
XMLTools[ElementStatistics](doc);
XMLTools[ContentModelCount](doc);
Return to Index for Example Worksheets
Download Help Document