You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Savita <sa...@india.hp.com> on 2002/05/07 14:08:40 UTC

Transformation of XML file

Hi,

Is it possible to transform a xml-file and a xsl file and get the output as an
xsl file.I am getting output as a document and a string.

If it is possible to transform a xml file and a xsl file and get a xsl file in
output please let me know how to do this .

Any help would be highly appreciated.

Thanks and Regards

Savita.


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Inserting a node

Posted by Savita <sa...@india.hp.com>.
Hi ,

I have a XML file like this
<MAP>
<ROOT>CUSTOMER_MSG</ROOT>
<PRIMARY>OS_CUST_ID</PRIMARY>
<GROUP>
<GROUP_NAME>CUSTOMER</GROUP_NAME>
<TABLE>
<TABLE_NAME>OS_CUSTOMER</TABLE_NAME>

<FIELD>
<FIELD_NAME>FIRST_NAME</FIELD_NAME>
<FIELD_TYPE>NVARCHAR</FIELD_TYPE>
</FIELD>

<FIELD>
<FIELD_NAME>LAST_NAME</FIELD_NAME>
<FIELD_TYPE>NVARCHAR</FIELD_TYPE>
</FIELD>

<FIELD>
<FIELD_NAME>CONTACT_TYPE</FIELD_NAME>
<FIELD_TYPE>CHAR</FIELD_TYPE>
</FIELD>

<FIELD>
<FIELD_NAME>ADDRESS_1</FIELD_NAME>
<FIELD_TYPE>NVARCHAR</FIELD_TYPE>
</FIELD>

<FIELD>
<FIELD_NAME>ADDRESS_2</FIELD_NAME>
<FIELD_TYPE>NVARCHAR</FIELD_TYPE>
</FIELD>

<FIELD>
<FIELD_NAME>ADDRESS_3</FIELD_NAME>
<FIELD_TYPE>NVARCHAR</FIELD_TYPE>
</FIELD>

<FIELD>
<FIELD_NAME>ADDRESS_4</FIELD_NAME>
<FIELD_TYPE>NVARCHAR</FIELD_TYPE>
</FIELD>
</TABLE>
</GROUP>
</MAP>

I am converting it in to an XML document.I am getting some value dynamically and then
after each FIELD_TYPE tag I want to insert two tag and values like<OSP_TABLE_NAME> and
<OSP_FIELD_NAME>.I am able to create the node but not able to insert the node.And after
inserting the node how do I get the l document back in to an xml file with this two
tags added in it.

Any pointer to this will be really helpfull for me.

Thanks and Regards
Savita.

Re: Transformation of XML file

Posted by Savita <sa...@india.hp.com>.
Hi Alistair & Scott,

I have still not got the solution for the problem.
1. Actually I am prepraring a XML file after selecting the name of the table and field
dynamically.something like this
<DATAMAP>
<MAPPING>
<ROOTELEMENT>Customer_id</ROOTELEMENT>
<tablename>
HP_CUSTOMER_ID_MAP
</tablename>
<fldname>
OS_CRM_EXCHANGE_CUSTOMER_ID
</fldname>
</MAPPING>
</DATAMAP>

2.After that there will be a Style sheet which will transform with this xml file to get
another style sheet.The first style sheet will look something like (not sure about the
syntax
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="XML"/>
<xsl:template match="ROOTELEMENT">
  <SQL>select <xsl:value-of select="tablename"/>.<xsl:value-of select="/fldname"/>
from<xsl:value-of select="tablename"/> </SQL>
</xsl:template>
</xsl:stylesheet>

3.So I should get another style sheet in out put something like
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="XML"/>
<xsl:template match="ROOTELEMENT">
  <SQL>select  customer.customer_id from customer </SQL>
</xsl:template>
</xsl:stylesheet>

and againg this xsl sheet should be transformed with a xml file.If I get the output
something like in step 3 then I can further transform it.

Is it posiible to do this.

Thanks and Regards

Savita.

Alistair Hopkins wrote:

> Yes, you can definitely do this: I know just what you mean.  Not exactly
> sure how...
>
> You want meta-templating:
>
> <xsl:template match="customer-id">
>   <xsl:for-each select="fieldname">
>         &lt;xsl:value-of select={.}/>
>   </xsl:for-each>
> </xsl:template>
>
> may work, OR try some namespace trickery:
> use the xsl: namespace qualifier in your metatemplate, then declare in the
> generated stylesheet that the default namespace is xsl: or vice versa: that
> should do it.
>
> <xsl:template match="customer-id">
>   <xsl:for-each select="fieldname">
>         <value-of select={.}/>  --this won't be processed by Xalan in preprocessing
>   </xsl:for-each>
> </xsl:template>
>
> hth,
>
> Al
>
> -----Original Message-----
> From: Scott Vachalek [mailto:scott@Integrisoft.COM]
> Sent: 08 May 2002 21:26
> To: xerces-j-user@xml.apache.org
> Subject: Re: Transformation of XML file
>
> Hmm, I'm still not sure what you mean when you say you want an XSL output
> file.  I'm going to assume FO, but XSLT is pretty easy to adapt to any kind
> of output.  For this you want to use Xalan (also from Apache) rather than
> Xerces.  If you write an XSLT like this:
>
> <xsl:template match="customer-id">
>   <fo:block><xsl:value-of select="tablename/fieldname"></fo:block>
> </xsl:template>
>
> you can extract all the "fieldname" text into a new document (in this case,
> inside XSL-FO "block" tags).
>
> ----- Original Message -----
> From: "Savita" <sa...@india.hp.com>
> To: <xe...@xml.apache.org>
> Sent: Tuesday, May 07, 2002 11:39 PM
> Subject: Re: Transformation of XML file
>
> > Hi Scott,
> >
> > I have a XML file.with come tags like
> > <customer_id><tablename><fieldname></fieldname></tablename></customerid>
> >
> > Now I have to prepare a xsl file with some select statement like select
> <xsl
> > value of: tablename,fieldname >from some table .
> >
> > and I have to get a XSL file where all the values will be replaced from
> the xml
> > file .
> >
> > Is it possible to do this pleas let me know .
> >
> > Thanks and Regards
> >
> > Savita
> >
> >
> > Scott Vachalek wrote:
> >
> > > Can you explain what you are trying to do in a little more detail?  XSLT
> > > converts an XML document into any almost any sort of text, so it's
> possible,
> > > but I don't understand exactly what you mean--you want to create a new
> XSLT
> > > document, or you want to create a FO file (FO is sometimes also called
> XSL)?
> > >
> > > ----- Original Message -----
> > > From: "Savita" <sa...@india.hp.com>
> > > To: <xe...@xml.apache.org>
> > > Sent: Tuesday, May 07, 2002 5:08 AM
> > > Subject: Transformation of XML file
> > >
> > > > Hi,
> > > >
> > > > Is it possible to transform a xml-file and a xsl file and get the
> output
> > > as an
> > > > xsl file.I am getting output as a document and a string.
> > > >
> > > > If it is possible to transform a xml file and a xsl file and get a xsl
> > > file in
> > > > output please let me know how to do this .
> > > >
> > > > Any help would be highly appreciated.
> > > >
> > > > Thanks and Regards
> > > >
> > > > Savita.
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.344 / Virus Database: 191 - Release Date: 02/04/2002
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.344 / Virus Database: 191 - Release Date: 02/04/2002
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


RE: Transformation of XML file

Posted by Alistair Hopkins <be...@btopenworld.com>.
Yes, you can definitely do this: I know just what you mean.  Not exactly
sure how...

You want meta-templating:

<xsl:template match="customer-id">
  <xsl:for-each select="fieldname">
	&lt;xsl:value-of select={.}/>
  </xsl:for-each>
</xsl:template>

may work, OR try some namespace trickery:
use the xsl: namespace qualifier in your metatemplate, then declare in the
generated stylesheet that the default namespace is xsl: or vice versa: that
should do it.

<xsl:template match="customer-id">
  <xsl:for-each select="fieldname">
	<value-of select={.}/>  --this won't be processed by Xalan in preprocessing
  </xsl:for-each>
</xsl:template>

hth,

Al

-----Original Message-----
From: Scott Vachalek [mailto:scott@Integrisoft.COM]
Sent: 08 May 2002 21:26
To: xerces-j-user@xml.apache.org
Subject: Re: Transformation of XML file


Hmm, I'm still not sure what you mean when you say you want an XSL output
file.  I'm going to assume FO, but XSLT is pretty easy to adapt to any kind
of output.  For this you want to use Xalan (also from Apache) rather than
Xerces.  If you write an XSLT like this:

<xsl:template match="customer-id">
  <fo:block><xsl:value-of select="tablename/fieldname"></fo:block>
</xsl:template>

you can extract all the "fieldname" text into a new document (in this case,
inside XSL-FO "block" tags).

----- Original Message -----
From: "Savita" <sa...@india.hp.com>
To: <xe...@xml.apache.org>
Sent: Tuesday, May 07, 2002 11:39 PM
Subject: Re: Transformation of XML file


> Hi Scott,
>
> I have a XML file.with come tags like
> <customer_id><tablename><fieldname></fieldname></tablename></customerid>
>
> Now I have to prepare a xsl file with some select statement like select
<xsl
> value of: tablename,fieldname >from some table .
>
> and I have to get a XSL file where all the values will be replaced from
the xml
> file .
>
> Is it possible to do this pleas let me know .
>
> Thanks and Regards
>
> Savita
>
>
> Scott Vachalek wrote:
>
> > Can you explain what you are trying to do in a little more detail?  XSLT
> > converts an XML document into any almost any sort of text, so it's
possible,
> > but I don't understand exactly what you mean--you want to create a new
XSLT
> > document, or you want to create a FO file (FO is sometimes also called
XSL)?
> >
> > ----- Original Message -----
> > From: "Savita" <sa...@india.hp.com>
> > To: <xe...@xml.apache.org>
> > Sent: Tuesday, May 07, 2002 5:08 AM
> > Subject: Transformation of XML file
> >
> > > Hi,
> > >
> > > Is it possible to transform a xml-file and a xsl file and get the
output
> > as an
> > > xsl file.I am getting output as a document and a string.
> > >
> > > If it is possible to transform a xml file and a xsl file and get a xsl
> > file in
> > > output please let me know how to do this .
> > >
> > > Any help would be highly appreciated.
> > >
> > > Thanks and Regards
> > >
> > > Savita.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.344 / Virus Database: 191 - Release Date: 02/04/2002

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.344 / Virus Database: 191 - Release Date: 02/04/2002


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Transformation of XML file

Posted by Scott Vachalek <sc...@Integrisoft.COM>.
Hmm, I'm still not sure what you mean when you say you want an XSL output
file.  I'm going to assume FO, but XSLT is pretty easy to adapt to any kind
of output.  For this you want to use Xalan (also from Apache) rather than
Xerces.  If you write an XSLT like this:

<xsl:template match="customer-id">
  <fo:block><xsl:value-of select="tablename/fieldname"></fo:block>
</xsl:template>

you can extract all the "fieldname" text into a new document (in this case,
inside XSL-FO "block" tags).

----- Original Message -----
From: "Savita" <sa...@india.hp.com>
To: <xe...@xml.apache.org>
Sent: Tuesday, May 07, 2002 11:39 PM
Subject: Re: Transformation of XML file


> Hi Scott,
>
> I have a XML file.with come tags like
> <customer_id><tablename><fieldname></fieldname></tablename></customerid>
>
> Now I have to prepare a xsl file with some select statement like select
<xsl
> value of: tablename,fieldname >from some table .
>
> and I have to get a XSL file where all the values will be replaced from
the xml
> file .
>
> Is it possible to do this pleas let me know .
>
> Thanks and Regards
>
> Savita
>
>
> Scott Vachalek wrote:
>
> > Can you explain what you are trying to do in a little more detail?  XSLT
> > converts an XML document into any almost any sort of text, so it's
possible,
> > but I don't understand exactly what you mean--you want to create a new
XSLT
> > document, or you want to create a FO file (FO is sometimes also called
XSL)?
> >
> > ----- Original Message -----
> > From: "Savita" <sa...@india.hp.com>
> > To: <xe...@xml.apache.org>
> > Sent: Tuesday, May 07, 2002 5:08 AM
> > Subject: Transformation of XML file
> >
> > > Hi,
> > >
> > > Is it possible to transform a xml-file and a xsl file and get the
output
> > as an
> > > xsl file.I am getting output as a document and a string.
> > >
> > > If it is possible to transform a xml file and a xsl file and get a xsl
> > file in
> > > output please let me know how to do this .
> > >
> > > Any help would be highly appreciated.
> > >
> > > Thanks and Regards
> > >
> > > Savita.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Transformation of XML file

Posted by Savita <sa...@india.hp.com>.
Hi Scott,

I have a XML file.with come tags like
<customer_id><tablename><fieldname></fieldname></tablename></customerid>

Now I have to prepare a xsl file with some select statement like select <xsl
value of: tablename,fieldname >from some table .

and I have to get a XSL file where all the values will be replaced from the xml
file .

Is it possible to do this pleas let me know .

Thanks and Regards

Savita


Scott Vachalek wrote:

> Can you explain what you are trying to do in a little more detail?  XSLT
> converts an XML document into any almost any sort of text, so it's possible,
> but I don't understand exactly what you mean--you want to create a new XSLT
> document, or you want to create a FO file (FO is sometimes also called XSL)?
>
> ----- Original Message -----
> From: "Savita" <sa...@india.hp.com>
> To: <xe...@xml.apache.org>
> Sent: Tuesday, May 07, 2002 5:08 AM
> Subject: Transformation of XML file
>
> > Hi,
> >
> > Is it possible to transform a xml-file and a xsl file and get the output
> as an
> > xsl file.I am getting output as a document and a string.
> >
> > If it is possible to transform a xml file and a xsl file and get a xsl
> file in
> > output please let me know how to do this .
> >
> > Any help would be highly appreciated.
> >
> > Thanks and Regards
> >
> > Savita.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Transformation of XML file

Posted by Scott Vachalek <sc...@Integrisoft.COM>.
Can you explain what you are trying to do in a little more detail?  XSLT
converts an XML document into any almost any sort of text, so it's possible,
but I don't understand exactly what you mean--you want to create a new XSLT
document, or you want to create a FO file (FO is sometimes also called XSL)?

----- Original Message -----
From: "Savita" <sa...@india.hp.com>
To: <xe...@xml.apache.org>
Sent: Tuesday, May 07, 2002 5:08 AM
Subject: Transformation of XML file


> Hi,
>
> Is it possible to transform a xml-file and a xsl file and get the output
as an
> xsl file.I am getting output as a document and a string.
>
> If it is possible to transform a xml file and a xsl file and get a xsl
file in
> output please let me know how to do this .
>
> Any help would be highly appreciated.
>
> Thanks and Regards
>
> Savita.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org