xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Suraj Kumar" <su...@rochester.rr.com>
Subject Re: create xsl programmatically using xalan API?
Date Fri, 14 May 2004 16:22:22 GMT
You can perhaps generate bunch of templates and store them in a single XSL.
If the intention  is to generate different XML output for same XML input
under different scenarios , you probably should invoke templates based on
mode attributes tagged to various templates. And select a mode by passing in
parameter to the stylesheet.

----- Original Message ----- 
From: "Jeffrey Hau" <jh398@doc.ic.ac.uk>
To: "Hall, Joe" <Joe.Hall@Avnet.com>
Cc: <xalan-j-users@xml.apache.org>
Sent: Friday, May 14, 2004 9:21 AM
Subject: Re: create xsl programmatically using xalan API?


>
> On 14 May 2004, at 14:16, Hall, Joe wrote:
>
> > Could you just use a StringBuffer containing xslt and pass it in as an
> > InputSource?
> sorry i think i didnt make myself clear.
>
> rather then creating an stylesheet, i mean constructing a stylesheet
> from scratch. so i want to be able to create different templates and
> add them to a stylesheet dynamically depending on my program logic.
> so rather than creating my own xsl element representation (see earlier
> reply to Henry), i am wondering if i could use xalan's templates
> package and how.
>
> thanks
>
> Jeff
>
> >
> > -----Original Message-----
> > From: Jeffrey Hau [mailto:jh398@doc.ic.ac.uk]
> > Sent: Friday, May 14, 2004 9:14 AM
> > To: Henry Zongaro
> > Cc: xalan-j-users@xml.apache.org
> > Subject: Re: create xsl programmatically using xalan API?
> >
> >
> >
> > On 14 May 2004, at 14:03, Henry Zongaro wrote:
> >
> >> Hi, Jeffrey.
> >>
> >> Jeffrey Hau <jh398@doc.ic.ac.uk> wrote on 2004-05-13 12:04:59 PM:
> >>> is there info on how to create xsl programmatically using the API? i
> >>> tried using various classes in the org.apache.xalan.templates package
> >>> but keep on running into errors when trying to nest elements. say
> >>> creating an element like,
> >>>
> >>> <xsl:template match="/">
> >>>    <html>
> >>> </xsl:template>
> >>>
> >>> i use the following code,
> >>>
> >>> Stylesheet sheet = new StylesheetRoot(null);
> >>> ElemTemplate template = new ElemTemplate();
> >>> template.setMatch(new XPath("/", null, null, XPath.MATCH));
> >>> template.setStylesheet(sheet);
> >>> org.w3c.dom.Element testEle = template.createElement("Test");
> >>> template.appendChild(testEle);
> >>
> >>      The easiest way I can think of would be to construct a DOM tree
> >> that
> >> represents your stylesheet,
> > that would be easy for a one off solution but i need more of an API to
> > give me the ease of creating xslt dynamically. to do that i will need
> > to create a whole lot of classes to represent various XSLT elements.
> > That's why i am looking at reusing the xalan templates classes instead
> > of creating my own representation.
> >
> >> and pass that into the
> >> TransformerFactory.newTransformer method inside of a DOMSource object.
> >>  Is
> >> that sufficient, or do you have some other requirement in addition to
> >> being able to create the stylesheet programmatically, that makes you
> >> want
> >> to use the classes in org.apache.xalan.templates directly?
> > i have no additional requirement apart from creating stylesheet
> > prgrammatically, but i would like to know if there is an API that i can
> > use, instead of creating my own.
> >
> > thanks
> >
> > Jeff
> >
> >>
> >> Thanks,
> >>
> >> Henry
> >> ------------------------------------------------------------------
> >> Henry Zongaro      Xalan development
> >> IBM SWS Toronto Lab   T/L 969-6044;  Phone +1 905 413-6044
> >> mailto:zongaro@ca.ibm.com
> >>
> >
>


Mime
View raw message