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 6087405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:52:00+00:00 2026-05-23T11:52:00+00:00

Is there some way to abuse XSLT as a builder/factory for objects instead of

  • 0

Is there some way to abuse XSLT as a builder/factory for objects instead of generating textual output? XPath-epressions alone are great for querying simple stuff, but get tedious in circumstances where I would use recursion in XSLT.

In other words, I’d like to use the template-matching semantics of XSLT, but each template would construct and return an object instead of a node or text.

The use case would be implementing a model transformator where the target model is not some XML stuff, but a custom domain model (as an object graph in memory).

  • 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-23T11:52:01+00:00Added an answer on May 23, 2026 at 11:52 am

    Interesting question, what you are asking is somewhat like the code generated by a parser generator like Alntlr would create.

    I think what you want is possible, by creating the objects as a side effect of the XSLT transform. You can create objects and call methods on objects from an XSLT script using code like this:

    Instantiate a Java object in your XSLT script;

    <!-- Create object factory. -->
    <xsl:variable name="factory" xmlns:java="http://xml.apache.org/xalan/java"
        select="java:my.sample.Factory.getInstance()" />
    

    Using it to create the object tree later on in the script:

    <xsl:template match="node">
        <xsl:variable name="myObject" xmlns:java="http://xml.apache.org/xalan/java"
                    select="java:getInstance($provider, string(@parent), string(@type))" />
    

    This would call the method getInstance(String, String) on the factory object created by the static getInstance() method on your my.sample.Factory class. The factory would also have to keep the objects created so that after the transform finishes you can retrieve the object tree instantiated by the transform from the factory instance. Instead of create the factory in the script you can create it beforehand and pass it to the script as a parameter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there some way I can use URLs like: http://www.blog.com/team-spirit/ instead of http://www.blog.com/?p=122 in
Is there some way to filter the blank lines from the displayed output in
Is there some way in PyQt to get a collection of all QLineEdit objects?
Is there some way to render all the literal objects and the literal objects
Is there some way to block access from a referrer using a .htaccess file
Is there some way to hide the browser toolbar / statusbar etc in current
Is there some way to cache a generated report in the reporting services, so
Is there some way I can define String[int] to avoid using String.CharAt(int) ?
Is there some way to get a value from the last inserted row? I
Is there some way to catch exceptions which are otherwise unhandled (including those thrown

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.