Download presentation
Presentation is loading. Please wait.
1
Use of Attribute Grammars to Construct XML translators Supervisor: Prof. John Hurst Presenter: Nishan Jayasinghe
2
Project Aim Project Aim Existing XML Translator XSLT Existing XML Translator XSLT Translator Writing Techniques Translator Writing Techniques The Translators & Difficulties Encountered The Translators & Difficulties Encountered What Was Learnt? What Was Learnt? Future Work and Conclusion Future Work and Conclusion Overview
3
Project Aim Can we translate XML using attribute grammars? Can we translate XML using attribute grammars? Is it simpler to translate XML with attribute grammars compared to existing solutions? Is it simpler to translate XML with attribute grammars compared to existing solutions? Is it possible to create a simpler specification language that represent attribute grammar computations? Is it possible to create a simpler specification language that represent attribute grammar computations?
4
Existing XML Translator Most popular method for translating XML is XSLT Most popular method for translating XML is XSLT XML document and specification are used by XSL processor to do the translation XML document and specification are used by XSL processor to do the translation AdvantagesDisadvantages Simple to update and maintain the XSLT specifications Simple to update and maintain the XSLT specifications Reuse specification using by including other specifications Reuse specification using by including other specifications XSLT s pecification syntax is complicated XSLT s pecification syntax is complicated
5
Translator Writing Techniques Subset of stages involved in constructing a compiler Subset of stages involved in constructing a compiler Lexical Analysis Syntax Analysis Semantic Analysis Why use these techniques? Why use these techniques? These techniques have been applied to other translator writing tasks Development time and effort shorter
6
Lexical Analysis Break up input document into tokens Break up input document into tokens Using Regular Expression Using Regular Expression XML for Beginners XML for Beginners StartName : StartName : DATA :[A-Za-z]+ EndName : EndName :
7
Syntax Analysis Describes the document structure Describes the document structure Using Context Free Grammar Using Context Free Grammar<book> XML for Beginners XML for Beginners J. Smith J. Smith </book> book: startBook name author endBook. name: startName DATA endName. author: startAuthor DATA endAuthor.
8
Semantic Analysis Describes computations that should occur given a particular context Describes computations that should occur given a particular context Using Attribute Grammar Using Attribute Grammar XML for Beginners XML for Beginners Title: XML for Beginners Using RULE: name ::= startName DATA endName COMPUTE name.output = Concatenate( “Title:”, DATA); END;
9
Input (XML document) Lexical AnalysisSyntax AnalysisSemantic Analysis Output (translated document) Document Processing
10
The Translators It is possible to translate XML documents It is possible to translate XML documents Created two translators XML to HTML XML to TEX
11
Our HTML Translator Output XSLT Output
12
Our TEX Translator Output XSLT Output
13
Display On a web browser
14
Difficulties Encountered We found that the translators can not deal with the following XSLT features We found that the translators can not deal with the following XSLT features White space characters outside the character data sections Changing of document structure from input document Length and complexity of Code
15
Code Size Example XSLT Counting Attribute Grammar ATTR depth: int INH; RULE: document ::= DocType article COMPUTE document.depth = 0; END; SYMBOL enumerate COMPUTE INH.depth = ADD(INCLUDING (enumerate.depth,document.depth), 1); END;
16
What Did We Learn? Writing Attribute Grammar translator is very time consuming compared with XSLT Writing Attribute Grammar translator is very time consuming compared with XSLT Difficult to learn some concepts The amount of code required for simple translator is not worth the effort But is possible to automatically generate (given the DTD) specifications using a simple algorithm for But is possible to automatically generate (given the DTD) specifications using a simple algorithm for Lexical Analysis specification Syntax Analysis specification
17
Algorithm for DTD to Lexical Specifications Lexical Tokens startBook : endBook : startName : endName : startAuthor : endAuthor : PCDATA : [A-Za-z]+
18
Algorithm for DTD to Syntax Specifications Context Free Grammar book : startBook name author endBook name : startName PCDATA endName author : startAuthor PCDATA endAuthor
19
Future Work Due to a lack of time we could not create a specification language that can be used instead of attribute grammars by users Due to a lack of time we could not create a specification language that can be used instead of attribute grammars by users Implement other XSLT functions such as sort Implement other XSLT functions such as sort Try extending the automatic generation of specifications to other types of document formats Try extending the automatic generation of specifications to other types of document formats
20
Conclusion We were able to translate XML documents using attribute grammars We were able to translate XML documents using attribute grammars We were able to reduce most of the time required for developing attribute grammar translator using automatically generated specifications We were able to reduce most of the time required for developing attribute grammar translator using automatically generated specifications It is clear at the moment XSLT is much simpler specification language from writing translations It is clear at the moment XSLT is much simpler specification language from writing translations
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.