RE: [xsl] Novice Question - matching entire text children

Subject: RE: [xsl] Novice Question - matching entire text children
From: "David Lee" <dlee@xxxxxxxxxxx>
Date: Mon, 20 Dec 2010 09:52:55 -0500
> Which should obviously work right ?

No, you can only match on nodes, not on primitive values.
What you can do is
   <xsl:template match="NODE">
     <xsl:value-of select="."/>
   </xsl:template>
========================================================================


I got that, but it was worth a try ....  Cant learn without pushing the
envelope !

That's why I wrote "Ha Silly Me".

I tried something that 'seemed obvious' to an XSLT novice to discover it was
a synatax error.

---
]



Now to answer the pressing question I guess I cant get away from answering
(because multiple people keep asking).

I'm writing XSLT *dynamically* based on a schema.   This is not hand-written
XSLT but very obtuse XSLT generated by XQuery based on a XSD Schema,
various annotations and external configuration files (with some Java thrown
in for fun).

( Part of my JSON/XSLT transformation experiment/project).

I need to *paramatize*  generation of different parts of an element in a
given element.

For example, an element like

	 <ELEM a1="value1" a2="value2">Text</ELEM>

I need to paramtize and independantly generate the rules for :

A) How to generate the element "ELEM" (various ways)
B) How to generate the attribute a1  (as apposed to attribute a2 which may
be generated differently)
C) What to do with text nodes.

I'm going to try to avoid the details  as there are many and I havent
written the paper yet :)

But I need to *conditionaly and parametrically* run different rules on
different parts of even a signle element.
These rules can be generated in different parts of the code.
I'm sure there are a million ways to do this, but XSLT with its pattern
matching capbility stood out as a good tool to use.

So for my *first attempt* I'm generating templates based on the element, its
attributes, AND ITS TEXT as separate templates.
e.g.

<template match="ELEM" .> ...
<template macth="ELEM/@a1"> ...
<template macth="ELEM/@a2"> ...
<template macth="ELEM/text()"> ...


These templates are generated in different parts of the code all based on
various configuration information and annotations in the schema.
SO I never know easily which rule is going to kick out where,  and I
certianly don't know within the generation of matchign for "ELEM" what the
coresponding templates to call are for its attributes or text ... so I just
pass the buck and am trying to leverage XSLT's pattern matching for me to
avoid the problem.
Trying to leverage FULL push matching instead of PULL matching so I can
decouple the rulebases ...

Beyond that I don't think I can explain better until I finish the code and
write the paper ... 
Its *kinda working* right now ... but trying to improve it.


(See you all at Balisage ??? )

-David


 





----------------------------------------
David A. Lee
dlee@xxxxxxxxxxx
http://www.xmlsh.org

Current Thread