Directions I would guess that it is static simply to allow calling it from the 
class rather than object, but I'm not certain. The xsltc code is a mixture of 
code donated by Sun and adaptations and maintenance by IBM, and I honestly 
don't understand it's internal architecture as well as I'd like.



--
   /_  Joe Kesselman (he/him/his)
-/ _) My Alexa skill for New Music/New Sounds fans:
   /   https://www.amazon.com/dp/B09WJ3H657/

Caveat: Opinionated old geezer with overcompensated writer's block. May be 
redundant, verbose, prolix, sesquipedalian, didactic, officious, or redundant.
________________________________
From: Andreas Martens (Jira) <j...@apache.org>
Sent: Wednesday, September 25, 2024 8:56:00 AM
To: dev@xalan.apache.org <dev@xalan.apache.org>
Subject: [jira] [Comment Edited] (XALANJ-2785) xsltc doesn't restart namespace 
numbering on transform


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

Andreas Martens edited comment on XALANJ-2785 at 9/25/24 12:55 PM:
-------------------------------------------------------------------

{{{{Ahh, in BasisLibrary.java:}}}}
{{{{    /**}}}}
{{{{     * This function is used in the execution of xsl:element}}}}
{{{{     */}}}}
{{{{    private static int prefixIndex = 0;        // not thread safe!!}}}}
{{{{    public static String generatePrefix() {}}}}
{{{{      return ("ns" + prefixIndex++);}}}}
{{    }}}



Which makes me wonder, why is this code static? I can't see any good reason for 
it!




was (Author: JIRAUSER307091):
{{Ahh, in BasisLibrary.java:}}
{{    /**}}
{{     * This function is used in the execution of xsl:element}}
{{     */}}
{{    private static int prefixIndex = 0;        // not thread safe!!}}
{{    public static String generatePrefix() {}}
{{      return ("ns" + prefixIndex++);}}
{{    }}}



Which makes me wonder, why is this code static? I can't see any good reason for 
it!



> xsltc doesn't restart namespace numbering on transform
> ------------------------------------------------------
>
>                 Key: XALANJ-2785
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2785
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in 
> Xalan projects.  Anybody can view the issue.)
>          Components: XSLTC
>    Affects Versions: 2.7.3
>         Environment: xSeries Linux
>            Reporter: Andreas Martens
>            Priority: Major
>         Attachments: TransformThread.java, foo0.xml, foo0.xsl
>
>
> When running a transform that generates namespaces in the output, the xsltc 
> transformer creates new namespaces with a monotonically increasing unique 
> number.
> I have modified the sample TransformerThread to illustrate the behaviour
> If I take a stylesheet:
> {{<?xml version="1.0" encoding="UTF-8"?>}}
> {{<xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
> xmlns:NS1="http://www.example.com/schema/wibble/1";>}}
> {{     <xsl:output omit-xml-declaration="yes" indent="yes"/>}}
> {{     <xsl:strip-space elements="*"/>}}
> {{     <xsl:template match="node() | @*">}}
> {{           <xsl:copy>}}
> {{                <xsl:apply-templates select="node() | @*"/>}}
> {{           </xsl:copy>}}
> {{     </xsl:template>}}
> {{     <xsl:template match="*[ancestor-or-self::wobble]">}}
> {{           <xsl:element name="\{name()}" 
> namespace="http://www.example.com/schema/wibble/1";>}}
> {{                <xsl:apply-templates select="node() | @*"/>}}
> {{           </xsl:element>}}
> {{     </xsl:template>}}
> {{</xsl:stylesheet>}}
>
> and apply it to xml:
> {{<wobble><inner><event/></inner></wobble>}}
>
> {{I get output:}}
> {{<ns928753:wobble xmlns:ns928753="http://www.example.com/schema/wibble/1";>}}
> {{<ns928754:inner xmlns:ns928754="http://www.example.com/schema/wibble/1";>}}
> {{<ns928755:event xmlns:ns928755="http://www.example.com/schema/wibble/1"/>}}
> {{</ns928754:inner>}}
> {{</ns928753:wobble>}}
>
> {{(it started at 0, I have simply run it a few more loops)}}
>
> {{It's *technically* valid output, but it's particularly {_}nice{_}...}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org
For additional commands, e-mail: dev-h...@xalan.apache.org

Reply via email to