GMPS : XSLT Fundamentals - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

GMPS : XSLT Fundamentals

Description:

A target is usually the name of a file that is generated by a program; ... You need to put a tab character at the beginning of every command line! ... – PowerPoint PPT presentation

Number of Views:96
Avg rating:3.0/5.0
Slides: 39
Provided by: berndkng
Category:

less

Transcript and Presenter's Notes

Title: GMPS : XSLT Fundamentals


1
  • GMPS XSLT Fundamentals

2
Contents
  • 1.0 Shortcut to the make philosophy
  • 1.1 Makefile fundamentals
  • 1.2 Make macros
  • 1.3 Automatic variables
  • 1.4 Multiple target definition
  • 2.0 xsltproc and XSLT
  • 2.1 XSLT fundamentals
  • 2.2 The main XSLT elements.
  • 2.3 Example

3
Contents
  • 3.0 GMPS and XSLT templates
  • 3.1 Predefined Macros and Templates
  • 3.1.1 Predefined Macros
  • 3.1.2 Predefined XSLT parameters
  • 3.1.3 Predefined templates
  • 3.2 Edit target.xml
  • 3.3 Edit tools.xml
  • 3.4 XSL- Template für ltRpcgengt
  • 3.5 Register XSLT template in
    templates_section.xml

4
1.0 Make Philosophy
  • The make utility automatically determines which
    pieces
  • of a large program, buildscript and so on
  • need to be recompiled, rerun and so on
  • and issues commands to recompile or run them.
  • You need a file called a makefile to tell make
    what to do.
  • Most often, the makefile tells make how to
    compile and link
  • a program.

5
1.0 Make Philosophy
  • What a Rule Looks Like
  • A simple makefile consists of "rules" with the
    following shape
  • target ... prerequisites ...
  • command
  • ...
  • ...
  • A target is usually the name of a file that is
    generated by a program
  • examples of targets are executable or object
    files. A target can also
  • be the name of an action to carry out, such as
    clean
  • (see section Phony Targets).

6
1.0 Make Philosophy
  • A prerequisite is a file that is used as input to
    create the target.
  • A target often depends on several files.
  • A command is an action that make carries out. A
    rule may have
  • more than one command, each on its own line.
  • Please note
  • You need to put a tab character at the beginning
    of every command line!
  • This is an obscurity that catches the unwary.
  • Usually a command is in a rule with prerequisites
    and serves to create
  • a target file if any of the prerequisites change.
  • However, the rule that specifies commands for the
    target need not have
  • prerequisites. For example, the rule containing
    the delete command associated with
  • the target 'clean' does not have prerequisites.

7
1.0 Make Philosophy
  • Example
  • .
  • .
  • newfile depfile
  • lttabgt cp depfile newfile
  • clean
  • lttabgt rm newfile

8
1.0 Make Philosophy
  • How work a flat file make utility like gnumake
    and so on
  • newfile depfile
  • cp depfile newfile
  • clean
  • rm newfile

if newfile dosnt exits build newfile if newfile
exits and the timetamp is older as the timestamp
from depfile rebuild newfile if newfile exits
and the timestamp is newer as the timestamp from
depfile newfile is up to date
target prerequisite
9
1.0 Make Philosophy
  • How work a make utility like clearmake/omake?
  • newfile depfile
  • cp depfile newfile
  • clean
  • rm newfile

if newfile dosnt exits build newfile if
newfile exits and its build with another version
from depfile or with another buildscript rebuild
newfile if newfile exits and its build with the
same version from depfile with the same
buildscript(command) newfile is up to date
target prerequisite
10
1.1 Makefile Fundamentals
  • newfile depfile
  • cp depfile newfile
  • .
  • Default makefile name for make is M(m)akefile
  • Otherwise
  • make f makefilename

target prerequisite command
11
1.2 Make Macros
  • CP /usr/bin/cp
  • ECHO /usr/bin/echo
  • newfile depfile
  • (ECHO) Create a new file
  • CP) depfile newfile
  • .

12
1.2 Make Macros
  • CP /usr/bin/cp
  • ECHO /usr/bin/echo
  • newfile depfile
  • _at_(ECHO) Create a new file
  • _at_(CP) depfile newfile
  • .
  • _at_ internal macro for silent mode

13
1.3 Automatic Variables
  • There are a lot auf predefined automatic
    vaiables
  • _at_ The file name of the target of the rule. If
    the target is an archive member, then '_at_'
  • is the name of the archive file. In a pattern
    rule that has multiple targets
  • (see section Introduction to Pattern
    Rules), '_at_' is the name of whichever target
  • caused the rule's commands to be run.
  • lt The name of the first prerequisite. If the
    target got its commands from an implicit rule,
  • this will be the first prerequisite added by the
    implicit rule.
  • CP /usr/bin/cp
  • ECHO /usr/bin/echo
  • newfile depfile
  • _at_(ECHO) Create a new file _at_
  • _at_(CP) lt _at_

14
1.4 Multiple Target definition
  • CP /usr/bin/cp
  • ECHO /usr/bin/echo
  • newfile2 newfile depfile
  • (ECHO) Create a new file
  • (CP) depfile newfile
  • .
  • newfile2
  • (ECHO) Create a new file2
  • (CP) depfile newfile2
  • .
  • .

15
2.0 XSLTPROC and XSLT
  • xsltproc is a command line tool for applying XSLT
    stylesheets to XML documents.
  • Xsltproc Call in GMPS
  • xsltproc -o Makefile Stylesheet XML-Document.
  • Stylesheet is generated by gms_make. It
    contents set of predefined in ../xsl-tmpl
    XSL-templates.
  • Which templates goes in this file determines
    gms_make itself.
  • XML-Document is generated by gms_make and
    contents set of configuration files (gms_config,
    gms_targets, target.xml etc). That is, all XML
    configuration files goes in one XML-Document.

16
2.1 XSL - templates
  • What is XSLT
  • XSLT is a W3C Recommendation.
  • XSLT transforms an XML document into another
    document.
  • XSLT uses XPath to navigate in XML documents.
  • How Does it Work?
  • In the transformation process, XSLT uses XPath
    to define parts of the source document that
    should match one or more predefined templates.
    When a match is found, XSLT will transform the
    matching part of the source document into the
    result document.

17
2.1 XSLT Fundamentals
  • How to Start?
  • The correct way to declare an XSL style sheet
    according to the W3C XSLT
  • Recommendation is
  • ltxslstylesheet version"1.0" xmlnsxsl"http//w
    ww.w3.org/1999/XSL/Transform"gt

18
2.2 The main XSLT Elements.
  • The ltxsltemplategt element is used to build
    templates.
  • You can build it with attribute name or
    match.
  • The match attribute is used to associate a
    template with an XML element.
  • The name attribute specifies a name for the
    template. One of this attributes must be
  • specified.

19
2.2 The main XSLT Elements.
  • The ltxslcall-templategt element calls a named
    template.
  • ltxslcall-template name"template name"gt
  • lt!-- xslwith-param --gt
  • lt/xslcall-templategt
  • The ltxslvalue-ofgt element can be used to extract
    the value of an XML element and add it
  • to the output stream of the transformation.

20
2.3 Example
  • File1
  • ltxsltemplate namefoogt
  • CppFlags ltxslvalue-of select_at_GlobalFlags/gt
  • lt/xsltemplategt
  • File2
  • ltxslstylesheet version"1.0" xmlnsxsl"http//ww
    w.w3.org/1999/XSL/Transform"gt
  • ltxsltemplate match/GmpsProject/Cppgt
  • CCSOURCES ltxslvalue-of select_at_GlobalSources/
    gt
  • ltxslcall-template namefoo/gt
  • lt/xsltemplategt
  • lt/xslstylesheetgt

21
2.3 Example
  • XML-doc
  • ltGmpsProjectgt
  • ltCpp
  • GlobalSources"mainfrm.cpp ex03a.cpp ex03adoc.cpp
    ex03aview.cpp"
  • GlobalFlags"-nologo -W3 -GX -D _WIN32 -D
    _WINDOWS -D _AFXDLL -D _MBCS -FD"
  • /gt
  • lt/GmpsProjectgt
  • Call
  • xsltproc File2 XML-doc
  • Output
  • CCSOURCES mainfrm.cpp ex03a.cpp ex03adoc.cpp
    ex03aview.cpp
  • CppFlags -nologo -W3 -GX -D _WIN32 -D _WINDOWS
    -D _AFXDLL -D _MBCS -FD

22
3.0 GMPS and XSL Templates
  • GMPS is more then a Makefile generator. GMPS is a
    process to produce software.
  • A user of GMPS can add own XSL templates to this
    process.
  • These are the steps
  • Edit target.xml.
  • Edit tools.xml, if the tool is not in tools.xml.
  • Define XSLT templates for target.xml and
    tools.xml.
  • Register templates in templates_section.xml.

23
3.1 Predefined Macros and Templates
  • The following is provides by GMPS and you can
    use it in your XSL templates
  • Predefine Makefile macros.
  • Predefine XSLT parameter.
  • Predefine XSLT templates.

24
3.1.1 Predefined Macros
  • (GMS_TARGET) the name of target, defined in
    target.xsl.
  • (OUTDIR) the output directory of target, it
    depends on the type of the target.
  • (TargetDoPath) the output directory of
    Makefile and derived objects
  • (VPATH) Makefile Standard Variable
  • (TargetSrcPath) - source directory of Target
  • In gms_abs.xml definds macros (Z.B. (ECHO),
    (RM) etc. see gms_abs.xml)

25
3.1.2 Predefined XSLT parameters
  • target the name of target whitout extention.
  • platform - gms_make is explained with this
    value of platform.
  • buildmode - gms_make is explained with this
    value of buildmode.
  • makefile name of Makefile
  • Example of use ltxslvalue-of selecttarget/gt.
    tlh

26
3.1.3 Predefined templates.
  • The template target_flags works on the
    following attributes of the tag from
  • lttargetgt.xml
  • GlobalFlags, ReleaseFlags, DebugFlags,
    LinuxGlobalFlags, LinuxReleaseFlags,
  • LinuxDebugFlags, Win32GlobalFlags,Win32DebugFlags,
    Win32releaseFlags.
  • The call
  • ltxslcall-template name"target_flags"gt
  • ltxslwith-param name"tool" select "Prefix of
    flagmacro. (z.B. Foo ) " /gt
  • lt/xslcall-templategt
  • Output
  • FooFlags
  • FooDebug oder FooRelease (von Buildmode
    abhgängig)

27
3.1.3 Predefined templates
  • The template "tool_flags" works on the following
    attributes of the tag from
  • tools.xml
  • GLOBAL_FLAGS, RELEASE_FLAGS, DEBUG_FLAGS,
    WIN32_GLOBLAL_FLAGS,
  • WIN32_RELEASE_FLAGS, WIN32_DEBUG_FLAGS,
    LINUX_GLOBAL_FLAGS,
  • LINUX_RELEASE_FLAGS, LINUX_DEBUG_FLAGS
  • The call
  • ltxslcall-template name"tool_flags"gt
  • ltxslwith-param name"name" select" 'Prefix des
    Flags'" /gt
  • ltxslwith-param name"path" select"//Name des
    Tags"/gt
  • lt/xslcall-templategt
  • Example
  • Prefix des Flags LD für LDLAGS
  • Name des Tages im Tools.xml LD
  • Output LDFLAGS, LDRELEASE oder LDDEBUG( abhängig
    von Buildmode)

28
3.1.3 Predefined templates
  • The template "Sources" converts source names
    from target.xml in name with
  • another extension. It is useful for getting for
    example object files (source.cpp -gt
  • source.obj).The template works on the following
    attributes
  • GlobalSources, ReleaseSources, DebugSources,LinuxG
    lobalSources,
  • LinuxReleaseSources, LinuxDebugSources,Win32Global
    Sources,
  • Win32DebugSources, Win32ReleaseSources
  • The Call
  • ltxslcall-template name"Sources"gt
  • ltxslwith-param name"macroname"
    select"'OBJFILES'"/gt
  • ltxslwith-param name"suffix" select" '.obj'
    "/gt
  • lt/xslcall-templategt
  • Output
  • OBJFILES source1.obj, source2.obj
  • Importan In the attributes must be sources with
    extension .

29
3.2 Edit target.xml.
  • The Structure of the target.xml
  • ltGmpsProjectgt
  • ltTarget Type Name/gt
  • ltFoo/gt
  • ltBar/gt
  • lt/GmpsProjectgt
  • In ltTargetgt define attribute Type or use one of
    predefined types (z.B. exe, dll). The
  • Attribute. The list of all predefined types is in
    gms_config.xml file.
  • Name is a name of target with extension (if
    exists).
  • For example
  • ltTarget
  • Type "rpcgen"
  • Name "tpsap"
  • /gt

30
3.2 Edit target.xml
  • In ltFoogt you can use all predefined source
    attributes and flags attributes.
  • You can also define new attributes.
  • ltRpcgen
  • RpcSources"tpsap.x CommonMaximumValues.x"
  • /gt
  • Oder
  • ltRpcgen
  • GlobalSource"tpsap.x CommonMaximumValues.x
  • /gt

31
3.3 Edit tools.xml .
  • Für ein neues Tool im tools.xml wird folgende
    Tag eingefügt
  • ltRPCGEN
  • WIN32_PATH""
  • LINUX_PATH""
  • GLOBAL_FLAGS" "
  • RELEASE_FLAGS""
  • DEBUG_FLAGS""
  • WIN32_GLOBLAL_FLAGS""
  • WIN32_RELEASE_FLAGS""
  • WIN32_DEBUG_FLAGS""
  • LINUX_GLOBAL_FLAGS""
  • LINUX_RELEASE_FLAGS""
  • LINUX_DEBUG_FLAGS""
  • /gt

32
3.4 XSL- Template für ltRpcgengt
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltxslstylesheet version"1.0" xmlnsxsl"http//ww
    w.w3.org/1999/XSL/Transform"gt
  • ltxsltemplate match"Rpcgen"gt
  • ltxslcall-template name"tool_flags"gt
  • ltxslwith-param name"name" select"'RPCGEN'" /gt
  • ltxslwith-param name"path" select"//RPCGEN"/gt
  • lt/xslcall-templategt
  • RPCGEN
  • ltxslcall-template name"Sources"gt
  • ltxslwith-param name"macroname"
    select"'RpcSources'"/gt
  • ltxslwith-param name"suffix" select" '.x' "/gt
  • lt/xslcall-templategt
  • hltxslvalue-of select"concat(substring-before(t
    arget, '_xdr'),'.h')"/gt
  • xltxslvalue-of select"concat(substring-before(t
    arget, '_xdr'),'.x')"/gt

33
3.4 XSL- Template für ltRpcgengt
  • (GMS_TARGET) (OUTDIR)/(GMS_TARGET)
  • (OUTDIR)/(GMS_TARGET) (RpcSources)
  • (RPCGEN) -h -o (TargetSrcPath)/(h) lt
  • (RPCGEN) -c -o (GMS_TARGET)
    (TargetSrcPath)/(x)
  • mv (TargetDoPath)/(GMS_TARGET) (OUTDIR)
  • clean
  • rm -rf (TargetSrcPath)/(h)
  • clean
  • rm -rf (OUTDIR)/(GMS_TARGET)
  • rm -f (MAKEFILE)
  • lt/xsltemplategt

34
3.4 XSL- Template für ltRpcgengt
  • Explanation of template.
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltxslstylesheet version"1.0" xmlnsxsl"http//ww
    w.w3.org/1999/XSL/Transform"gt
  • This is a correct way to declare an XSL style
    sheet according to the W3C XSLT
  • Recommendation.
  • ltxsltemplate match"Rpcgen"gt
  • The match attribute is used to associate a
    template with an Rpcgen element.
  • ltxslcall-template name"tool_flags"gt
  • ltxslwith-param name"name" select"'RPCGEN'" /gt
  • ltxslwith-param name"path" select"//RPCGEN"/gt
  • lt/xslcall-templategt
  • The template creates RPCGENFLAGS RPCGENRELEASE
    or RPCGENDEBUG macros
  • with content of RPCGEN XML element from
    tools.xml.

35
3.4 XSL- Template für ltRpcgengt
  • RPCGEN
  • ltxslcall-template name"Sources"gt
  • ltxslwith-param name"macroname"
    select"'RpcSources'"/gt
  • ltxslwith-param name"suffix" select" '.x' "/gt
  • lt/xslcall-templategt
  • If you declare im target.xml
  • ltRpcgen
  • GlobalSource"tpsap.x CommonMaximumValues.x
  • /gt
  • you can use predefined Source template. This
    makes macro RpcSources. But in this case is
  • easier to declare so
  • RpcSourcesltxslvalue-of select_at_GlobalSources/gt
    .

36
3.4 XSL- template für ltRpcgengt
  • hltxslvalue-of select"concat(substring-before(t
    arget, '_xdr'),'.h')"/gt
  • xltxslvalue-of select"concat(substring-before(t
    arget, '_xdr'),'.x')"/gt
  • Use target GMPS predefined XSLT parameter to get
    names as
  • lttargetgt.extension. Here targettpsap_xdr. So we
    use substring-before(target,'_xdr')
  • function to get macros.
  • htpsap.h
  • xtpsap.x

37
3.4 XSL- Template für ltRpcgengt
  • (GMS_TARGET) (OUTDIR)/(GMS_TARGET)
  • (OUTDIR)/(GMS_TARGET) (RpcSources)
  • (RPCGEN) -h -o (TargetSrcPath)/(h) lt
  • (RPCGEN) -c -o (GMS_TARGET)
    (TargetSrcPath)/(x)
  • mv (TargetDoPath)/(GMS_TARGET) (OUTDIR)
  • This is Makefile syntax. For xsltporoc this is
    plain text.
  • As a clean section
  • clean
  • rm -rf (TargetSrcPath)/(h)
  • rm -rf (OUTDIR)/(GMS_TARGET)
  • rm -f (MAKEFILE)

38
3.5 Register XSLT template in templates_section.xm
l
  • The entries for every line are
  • lttemplate nameRpcgen filerpcgen.xsl"/gt
Write a Comment
User Comments (0)
About PowerShow.com