david wrote:
Hi, Steffen
Thanks for your answer and for the xsltproc link.
I' ve seen the differencies between my file and dia-uml2cpp.xsl. but I
think's its ok because :
<xsl:output method="text"/> <- output file (it's xml
for me)
I don't use thes parameters :
<xsl:param name="directory"/>
<xsl:param name="indentation"><xsl:text>
</xsl:text></xsl:param>
<xsl:template match="dia-uml">
The dia file what I want convert does'nt contain the "dia-uml" markup
I've tried to add the xsl namespace and to remove dia: prefixes but
without changes...
This is the beginning of my file (with one template, if it works for
this one, it works for all !) :
[...]
The file's header looks OK, but templates look strange. Typically if
you want a template that parses some element you use one element in its
match attribute. If you want to apply some specific template you call
it by name.
Here is an example (a part of a bigger XSL)
<xsl:template match="tr">
<tr>
<xsl:apply-templates />
</tr>
</xsl:template>
<xsl:template match="td">
<td class="{ class}" colspan="{ colspan}">
<xsl:apply-templates />
</td>
</xsl:template>
Note that when you use <xsl:apply-templates /> you will tell XSL
engine to parse all sub nodes (including text nodes) and so in above
example any <tr> would be parsed as is (but without attributes),
if there would be <td> inside it would be parsed and any elements
inside <td> would be omitted, but text nodes which by default are
outputted as is. So e.g from this:
<tr style="color:blue">
<td style="color:blue">
<b>ab<i>c</i></b>
</td>
</tr>
You will get:
<tr>
<td>
abc
</td>
</tr>
Of course in above example your <xsl:template match="/"> would
have to include some kind of <xsl:apply-templates ... />. And
note again that you shouldn't use "//" in match attribute of templates
- it matches any elements any way. Using my example again from this:
<tr><td>test</td></tr>
<td class="test" style="display:inline">not in a row</td>
<blah><td>cell in something else</td></blah>
You will get this:
<tr><td>test</td></tr>
<td class="test">not in a row</td>
<td>cell in something else</td>
Note that all <td> elements got parsed. But if in
<xsl:template match="/"> you would have <xsl:template
match="//tr"> you would only get:
<tr><td>test</td></tr>
(in reality you would get empty class and colspan attributes in output,
but I've omitted this for clarity)
Regards,
Nux.