Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] applying templates to attribute value

From: Wendell Piez <wapiez@---------------->
To:
Date: 7/1/2008 6:12:00 PM
At 12:30 PM 7/1/2008, you wrote:
> Actually, as Ken said, to write the attribute value you should use
> xsl:value-of. xsl:apply-templates should not work: if it does, your
> processor is not being conformant, and your code will break in
> another processor.

actually the default template for attributes does the same as value-of
in this case.

Yes, but if you apply templates when matching an attribute, there are 
no nodes to apply templates to:



<xsl:template match="@*">
  <xsl:apply-templates/>
</xsl:template>

If you apply templates to an attribute, you get its value (by default).



<xsl:template match="*">
  <xsl:apply-templates select="@*/>
</xsl:template>

(Maybe this was what was meant, in which case I apologize for 
confusing things, and thanks for the clarification in any case.)



> Sometimes they bend the rules and introduce some
> sort of structure into attribute values, but when they do, it's
> always simple enough to parse easily (for example tokenized values,
> or maybe tokenized values with labels), since this generally has to
> be done in the application not by the XML parser.

Of course it is possible to parse reasonably complicated "quoted html in
attributes" just using xslt if you want to avoid extension functions.
Just bash the attribute value with enough regular expressions and
generate some element nodes... (see htmlparse.xsl for some examples of
this).

But this isn't something I would wish on a beginner. You have to be 
both adept at plain-text processing and at composing complex logic in XSLT.



BTW, I take it you mean XSLT 2.0, for those regexps w/o extension?



I dare say even an expert will put the code into a library so it 
doesn't have to be redone. :-)



Cheers,
Wendell


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent