Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6167777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:34:17+00:00 2026-05-23T22:34:17+00:00

This is my XML file and If i run the XSLt file i’ll get

  • 0

This is my XML file and If i run the XSLt file i’ll get the same output in the same order exactly in Eclipse XSL Transformation.
Even if add a new record to my xml file and run the XSL file, the <xsl:value-of select="generate-id(.)"/> will create unique id for the new record.

<?xml version="1.0" encoding="UTF-8"?>
<CONTACTS>

<CONTACT>
<Customer-ID>N65539</Customer-ID>
<FirstName>Ben</FirstName>
<LastName>Foden</LastName>
<email></email>
<address></address>
<state>AZ</state>
<country>US</country>
</CONTACT>

<CONTACT>
<Customer-ID>N65539</Customer-ID>
<FirstName>Nimal</FirstName>
<LastName>Anup</LastName>
<email>nimal.anup@gmail.com</email>
<address></address>
<state>TN</state>
<country>IN</country>
</CONTACT>


<CONTACTS>

This is my updated XSLT file:

  <?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" />

<!--Identity template to copy content forward-->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
</xsl:template>

    <xsl:template match="CONTACT">
<xsl:copy>
    <Customer-ID>
    <xsl:apply-templates select="node()" mode="generate-id"/>
    </Customer-ID>

    <FirstName>
    <xsl:value-of select="FirstName"/> 
    </FirstName>

    <LastName>
    <xsl:value-of select="LastName"/> 
    </LastName>

    <email>
    <xsl:value-of select="email"/> 
    </email>

    <address>
    <xsl:value-of select="address"/> 
    </address>

    <state>
    <xsl:value-of select="state"/> 
    </state>

    <country>
    <xsl:value-of select="country"/> 
    </country>

</xsl:copy>
    </xsl:template>

    <xsl:template match="node()" mode="generate-id">
    <xsl:text>N</xsl:text>
    <xsl:number level="single" count="node()" format="100"/>        
    </xsl:template>

</xsl:stylesheet>

Then I used the same XSLT file for XSLT processor function in XUL, which I’m getting a different type of ID and output.
It’s keep generating a new ID for old record and for new record If i add a new record in XML file.

How do i generate a new id only for the new record? and how can i have the same XML template of my input file to my XML output file.

This is the output i’m getting:

<?xml version="1.0" encoding="UTF-8"?>
<CONTACTS>

<CONTACT><Customer-ID>id0x03e4a620</Customer-ID><FirstName>Ben</FirstName><LastName>Foden</LastName><email></email><address></address><state>AZ</state><country>US</country></CONTACT>

<CONTACT><Customer-ID>id0x03e4ad80</Customer-ID><FirstName>Nimal</FirstName><LastName>Anup</LastName><email>nimal.anup@gmail.com</email><address></address><state>TN</state><country>IN</country></CONTACT>

<CONTACTS>

This is my Javascript to call the XSLT file: The script call this function after saving the XML file. The new record will update in the same as mentioned in the input xml file.

function process()
{

var src = readFile("c:\\idgenerator.xsl");
var parsed = (new DOMParser()).parseFromString(src, "text/xml");
var stylesheet = parsed.documentElement;

var processor = new XSLTProcessor();
processor.importStylesheet(stylesheet );

objXMLDoc = processor.transformToDocument(objXMLDoc);

var serializer = new XMLSerializer();
var prettyString = serializer.serializeToString(objXMLDoc);

saveFile(prettyString, "C:\\mercredi.xml");

} 

Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:34:17+00:00Added an answer on May 23, 2026 at 10:34 pm

    I don’t know what XSLT processor Eclipse uses. At least with some extensions, you can configure the processor, e.g. to Xalan or Saxon.
    Mozilla/XUL uses Transformiix, at least by default. I read somewhere that it could be made to use Saxon.
    There are certainly differences between different XSLT processors.

    The specification for generate-id() does not say what the generated ids should look like; only that they “must consist of ASCII alphanumeric characters and must start with an alphabetic character”.

    If you want XSLT-under-XUL to produce the same kinds of IDs as under Eclipse, you have a couple of options.

    1) You could try and get XUL to use the XSLT processor that Eclipse uses. I don’t know if this is possible.

    2) Implement your own custom template for generating IDs.

    With the latter, it would not be hard to imitate the style of the IDs you get in Eclipse, and to make them stable across multiple runs and different XSLT processors, if you have some stable data to base them on.

    For example, if the order of your records is always stable (old records will never be deleted, or swapped, or replaced), then you could use a template like this to generate IDs:

    <xsl:template match="node()" mode="generate-id">
        <xsl:text>N</xsl:text>
        <xsl:number level="any" count="node()" format="00001"/>        
    </xsl:template>
    

    If the order is not stable, but the first name + last name is both stable and unique, you could use

    <xsl:template match="node()" mode="generate-id">
       <xsl:value-of select="concat(FirstName, LastName)" />
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With this XML file - <Instructions> <Admin> <Instruction> Steps must be completed in order.&lt;/br&gt;
I'm trying to post-process the documentation XML file as a post-build XSLT transformation (using
This is my xml file: <?xml version=1.0?> <?xml-stylesheet type=text/xsl href=hello.xsl?> <message> <greeting>Hello World!</greeting> </message>
This is my Xml file.i want to transform this xml file into another customized
I have this xml file which has text init. i.e Hi my name is
I got this XML file: <Msg UserText=start 0> </Msg> <Msg UserText=A> </Msg> <Msg UserText=A>
I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I am receiving this XML file which I would like to validate. Ideally I
I have thread where downloading xml file a this xml file i want to
I am using an XML file to store the values. This XML file can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.