[ 
http://issues.apache.org/jira/browse/XALANJ-1497?page=comments#action_12369492 
] 

Brian Minchau commented on XALANJ-1497:
---------------------------------------

For XML produced from a transformation one never knows how it will be used.
Suppose that one produces this:
<?xml version='1.0' encoding='UTF-8'?><?PI-one?>  <!-- comment one -->  
<elem1><elem2>hello</elem2></elem1>

Suppose that one serialized with indent='yes'.  Where could whitespace (e.g. 
newlines and spaces for indentation) be inserted?
In this case only between <elem1> and <elem2>, or between </elem2> and 
</elem1>. 

Adding whitespace before or after a top level PI, comment or whitespace text 
node may not be correct because this XML could be used as an external general 
parsed entity.  For example suppose that a it was refered to as &egpe; and 
included in other XML like this:

<e>some text&egpe;more text</e>

In this case (and so in general) it is not correct to add whitespace to the top 
level of serialized XML as that whitespace will occur after "some text" or 
perhaps before "more text".  The producer of the serialized XML can not know 
the context in which that XML will later be used.

So even with indentation='yes' we should not put additional whitespace between 
top level nodes, not even a newline after an XML header!
One can only add whitespace for indentation within an element. In the above 
example indentation, if any, would be within the <elem1> and </elem1> tags, so 
indentation could look like this:

<?xml version='1.0' encoding='UTF-8'?><?PI-one?>  <!-- comment one -->  <elem1>
  <elem2>hello</elem2>
</elem1>




> xsl:copy adds a newline to processing instructions
> --------------------------------------------------
>
>          Key: XALANJ-1497
>          URL: http://issues.apache.org/jira/browse/XALANJ-1497
>      Project: XalanJ2
>         Type: Bug
>   Components: transformation, Xalan-interpretive
>     Versions: 2.5
>  Environment: Operating System: Other
> Platform: Other
>     Reporter: dcaveney
>     Assignee: Brian Minchau
>  Attachments: d19306.xml, d19306.xsl
>
> <xsl:copy> produces a node AND a linefeed for processing-instruction nodes in 
> the "root" of the document.
> Example:
> The following template faithfully reproduces an XML document:
> <xsl:template match="node() | @*">
> <xsl:copy>
> <xsl:apply-templates select="node() | @*"/>
> </xsl:copy>
> </xsl:template>
> ...EXCEPT when the document contains processing instruction nodes in the
> "root" (ie. before the "document" element). There doesn't seem to be a problem
> for nodes that are descendants of the "document" element.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to