[ 
https://issues.apache.org/jira/browse/XALANJ-1387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15411741#comment-15411741
 ] 

Robert Papp edited comment on XALANJ-1387 at 8/8/16 12:41 PM:
--------------------------------------------------------------

Funny enough that reversal is not random order, so you keep track of which 
attribute came first. I think it's likely a choice of data structure: somewhere 
there may be a {{Stack}}, or using {{addFirst}} on a {{LinkedList}}. So Xalan 
is aware of the order, because it's *consistently* reversing attributes 
regardless of name, element, value.

Here's a workaround that produces the expected result: use {{xsl:attribute}} s.
{code}
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
        <xsl:output method="xml" />
        <xsl:template match="/root">
                <!-- out 3-2-1 -->
                <element attr1="val1" attr2="val2" attr3="val3" />
                <!-- out 1-2-3 -->
                <element attr3="val3" attr2="val2" attr1="val1" />
                <!-- out 1-2-3 -->
                <element>
                        <xsl:attribute name="attr1">val1</xsl:attribute>
                        <xsl:attribute name="attr2">val2</xsl:attribute>
                        <xsl:attribute name="attr3">val3</xsl:attribute>
                </element>
        </xsl:template>
</xsl:stylesheet>
{code}



was (Author: twisterrob):
Funny enough that reversal is not random order (i.e. , so you keep track of 
which attribute came first. I think it's likely a choice of data structure: 
somewhere there may be a stack. So Xalan is aware of the order, because it's 
*consistently* reversing attributes regardless of name, element, value.

Here's a workaround that produces the expected result: use {{xsl:attribute}} s.
{code}
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
        <xsl:output method="xml" />
        <xsl:template match="/root">
                <!-- out 3-2-1 -->
                <element attr1="val1" attr2="val2" attr3="val3" />
                <!-- out 1-2-3 -->
                <element attr3="val3" attr2="val2" attr1="val1" />
                <!-- out 1-2-3 -->
                <element>
                        <xsl:attribute name="attr1">val1</xsl:attribute>
                        <xsl:attribute name="attr2">val2</xsl:attribute>
                        <xsl:attribute name="attr3">val3</xsl:attribute>
                </element>
        </xsl:template>
</xsl:stylesheet>
{code}


> order of HTML attributes are reversed when parsed
> -------------------------------------------------
>
>                 Key: XALANJ-1387
>                 URL: https://issues.apache.org/jira/browse/XALANJ-1387
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in 
> Xalan projects.  Anybody can view the issue.) 
>          Components: Xalan
>    Affects Versions: 2.0.0
>         Environment: Operating System: Windows NT/2K
> Platform: PC
>            Reporter: Ronny Krite
>
> When the XML / XSLT have been parsed, the results show that the order of the 
> attributes are reversed.
> go to here....
> http://www.alistapart.com/stories/xslt/demo.html
> Then choose....
> "Now you're cooking catalog xml"
> Then Choose...
> "Fancy output"
> Then Choose...
> "Source for HTML result"
> Look in the bottom two frames that the attributes of the <table> tag are 
> reversed.... as such....
>    <table border="0" cellspacing="4">
> ... and ...
>    <table cellspacing="4" border="0">
> Thanks



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to