XSLT Flashcards

1
Q

What is XSLT and why is it used (especially over DOM)?

A

DOM can be overkill for small transformations. XSLT allows you to modify the structure without expensive Java methods.

  • Uses XML Syntax
  • The use of XPATH lets you navigate through the tree
  • Can complete lots of transformations (generation/duplication/moving etc)
  • Can calculate new content or structure based on the source code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

XSLT is stylesheet transformation.

Why can’t you use it in place of CSS?

A

XSLT doesn’t actually change the style of the XML in the same sense as CSS but changes the styles structure.

XSLT transform one DTD/Schema to another!

XSLT + CSS = STYLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you start writing xslt?

A

Start with a namespace (shown attached).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In XPATH, what is the Context Node?

A

The context is the Current Node (current pointer)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are XPATH navigation expressions?

Tip: There are 10.

A

Each of these expressions start from the context node unless specified.

  1. . : selects context node
  2. .. : parent of the context
  3. // : all descendants of the context node
  4. foo : all child nodes with the name ‘foo’
  5. @foo :all attributes of context with name ‘foo’
  6. * : selects all child nodes
  7. @* :selects all attributes of the context
  8. text() : selects the value of only the text child nodes.
  9. node() : selects all child node values regardless of type.
  10. / : selects the root

Examples:

../chapter/title/@subtitle

//note/text()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are predicates and show an example

A

Predicates allow you to filter on path expressions.
They can match against attributes or elements

Examples:
book/title[@subtitle=”or what you will”]
book[title=’Twelve Night’]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you add functions to Predicates?

A

Within the predicate.

book[count(chapter) > 10]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What would be the result of the attached xslt agasint the attached xml?

A

Answer attached.

The xslt transformation can happen at the client of the server.

We see the original source code when we apply on the Client Side. The browser has done the transformation for us.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly