diff options
-rw-r--r-- | documentation/xslt.md | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/documentation/xslt.md b/documentation/xslt.md new file mode 100644 index 0000000..56d800b --- /dev/null +++ b/documentation/xslt.md @@ -0,0 +1,83 @@ +## XML TRANSFORMATION ## +@amit + + +---------- +This documentation contains description and steps used to construct eXtensible stylesheet for converting GUI obtained xml into Scilab compatible xml. + +---------- + +###Introduction +XSL stands for EXtensible Stylesheet Language, and is a style sheet language for XML documents. XSLT is used to transform an XML document into another XML document, or another type of document that is recognized by a browser, like HTML and XHTML. +We took help of XCOS's XML Schema ( XML Schema defines the legal building blocks of an XML document ) to convert xml generated by GUI into Scilab compatible xml. + +###XSLT Overview + + - XSLT "xsl:template" Element : The "xsl:template" element is used to build templates and its match attribute is used to associate a template with an XML element. + - XSLT "xsl:value-of" Element : The "xsl:value-of" element is used to extract the value of an XML element and add it to the output stream of the transformation. + - XSLT "xsl:if" Element : The "xsl:if" Element is used to put a conditional if test against the content of the XML file. + - XSLT "xsl:choose" Element : The "xsl:choose" element is used in conjunction with "xsl:when" and "xsl:otherwise" to express multiple conditional tests. + - XSLT "xsl:apply-templates" Element : The "xsl:apply-templates" element applies a template to the current element or to the current element's child nodes. + - XSLT "xsl:element" Element : The "xsl:element" element is used to create an element node in the output document and "xsl:attribute" element is used to add attributes to elements. + + +###XSLT Description + + - First of all we use"xsl:template match="/" " to define the whole document and make element "XcosDiagram" for our Scilab compatible xml. + - Then we use "xsl:template match="mxCell" " and "xsl:choose" Element to express multiple conditional tests according to "style" attribute of "mxCell". + - Then we define templates for all the xcos' blocks and ports with the help of XCOS's xsd (XML Schema) which are recursively called by "xsl:apply-templates/" as and when encountered by GUI generated xml. + - According to XCOS's xsd (XML Schema) following elements can occur inside "root" element of GUI generated xml and we have to define template for each of them using XCOS's xsd. + - "BasicBlock" + - "CommandPort" + - "ControlPort" + - "ExplicitInputPort" + - "ExplicitOutputPort" + - "ImplicitInputPort" + - "ImplicitOutputPort" + - "mxCell" + - "AfficheBlock" + - "BigSom" + - "CommandControlLink" + - "ConstBlock" + - "EventInBlock" + - "EventOutBlock" + - "ExplicitInBlock" + - "ExplicitLink" + - "ExplicitOutBlock" + - "GainBlock" + - "GroundBlock" + - "ImplicitInBlock" + - "ImplicitLink" + - "ImplicitOutBlock" + - "PrintBlock" + - "Product" + - "RoundBlock" + - "SplitBlock" + - "Summation" + - "SuperBlock" + - "TextBlock" + - "VoltageSensorBlock" + - For eg. "ExplicitLink" element can have "id" ,"style" ,"value" as its attribute. So we will define its template as : + + + <xsl:template name="ExplicitLink" match="ExplicitLink"> + <xsl:element name="ExplicitLink"> + <xsl:if test="@id"> + <xsl:attribute name="id"> + <xsl:value-of select="@id" /> + </xsl:attribute> + </xsl:if> + <xsl:if test="@style"> + <xsl:attribute name="style"> + <xsl:value-of select="@style" /> + </xsl:attribute> + </xsl:if> + <xsl:if test="@value"> + <xsl:attribute name="value"> + <xsl:value-of select="@value" /> + </xsl:attribute> + </xsl:if> + <xsl:apply-templates /> + </xsl:element> + </xsl:template> + |