[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] What is @xml:space about?
- From: "G. Ken Holman" <gkholman@CraneSoftwrights.com>
- To: xml-dev@lists.xml.org
- Date: Tue, 10 Jul 2012 11:44:31 -0400
At 2012-07-10 11:36 -0400, John P. McCaskey wrote:
>On 7/10/2012 11:00 AM, Michael Kay wrote:
>
>>I don't know of any applications that use this attribute for any
>>purpose other than to decide whether whitespace-only text nodes
>>should be preserved,
>
>For stripping whitespace-only text nodes, <xsl:strip-space> would be
>more efficient and would avoid counting such nodes with count(). Yes?
Perhaps ... though I think the stylesheet writer should simply be
aware of the document model and not rely on any automatic stripping.
>The examples in 2.10 White Space Handling seem good, viz., use
>xml:space='preserve' for source code and poetry, things that in
>(old) HTML would naturally get put in <pre>. I'd have thought using
>xml:space as intended would not be rare. It seems a pretty useful attribute.
>
>I see that XALAN lets xml:space=preserve override xsl:strip-space
>(http://xml.apache.org/xalan-j/xsltc/xsl_whitespace_design.html). Is
>that in a spec?
Yes, see http://www.w3.org/TR/2007/REC-xslt20-20070123/#strip where it reads:
A whitespace text node is preserved if either of the following apply:
The element name of the parent of the text node is in the set of
whitespace-preserving element names.
An ancestor element of the text node has an xml:space attribute with
a value of preserve, and no closer ancestor element has xml:space
with a value of default.
>Do all XSLT processors do that?
I believe they should all follow the spec and have
xml:space="preserve" override xsl:strip-space. I don't think a
stylesheet writer should override a user's claim that their data has
significant white-space-only text nodes. If a user states that their
element content white space nodes "mean" something to them, then I
don't think any implicit or explicit stripping by the stylesheet
writer using directives should touch them. Of course the stylesheet
writer can choose to ignore them in their logic, but not in any
declarative pruning of the source node tree.
I hope this helps.
. . . . . . . . . Ken
--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- Oct 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/
G. Ken Holman mailto:gkholman@CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]