You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Alan Andrade <al...@insurity.com> on 2007/01/30 00:39:12 UTC
can xalan transform 2 xml using one xslt?
Here is my problem
I have an
xml A
<page>
<location>
<locid>1<locid>
<vehicle>
<id>1</id>
</vehicle>
<vehicle>
<id>2</id>
</vehicle>
</ location >
<location>
<locid>2<locid>
<vehicle>
<id>1</id>
</vehicle>
</ location >
</page>
XML B
<prices>
<location>
<vehicle>
<locationid>1<locationid>
<id>1</id>
<price>25000</price>
</vehicle>
<vehicle>
<locationid>1<locationid>
<id>2</id>
<price>5000</price>
</vehicle>
<vehicle>
<locationid>2<locationid>
<id>1</id>
<price>9000</price>
</vehicle>
</location>
</prices>
After transformation I need the out put xml to be
<page>
<location>
<locid>1<locid>
<vehicle>
<id>1</id>
<price>25000</price>
</vehicle>
<vehicle>
<id>2</id>
<price>5000</price>
</vehicle>
</ location >
<location>
<locid>2<locid>
<vehicle>
<id>1</id>
<price>9000</price>
</vehicle>
</ location >
</page>
How do I do this?
Thanks
Alan
Alan Andrade | alan.andrade@insurity.com
<ma...@insurity.com>
-----------------------------------------
The information contained in this e-mail message is intended only
for the personal and confidential use of the recipient(s) named
above. This message may be an attorney-client communication and/or
work product and as such is privileged and confidential. If the
reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are
hereby notified that you have received this document in error and
that any review, dissemination, distribution, or copying of this
message is strictly prohibited. If you have received this
communication in error, please notify us immediately by e-mail, and
delete the original message.
RE: can xalan transform 2 xml using one xslt?
Posted by Kevin Cormier <kc...@ca.ibm.com>.
Hi Alan,
This should be fairly straightforward to accomplish. You'll need to set up
your templates so that when you are processing <loc> elements, you do not
copy <PDSCov> elements to the output. In your template for <lbLocs>, you
could use an xsl:for-each to loop over the <lbloc>elements, recording the
position() of each in a variable, and using it to fetch the corresponding
<loc> element.
You should be able to find lots of XSLT resources online to help you out
with this.
Kevin Cormier
Software Developer, XSLT Development
IBM Toronto Lab, D1-435
E-mail: kcormier@ca.ibm.com
"Alan Andrade"
<alan.andrade@ins
urity.com> To
<xa...@xml.apache.org>
04/23/2007 06:38 cc
PM
Subject
RE: can xalan transform 2 xml using
one xslt?
Here is my problem
XML Input
<root>
<locs>
<loc>
<locno>1</locno>
<bldno>1</bldno>
<PDSCov>
<PDSCLSCode>232323</PDSCLSCode>
</PDSCov>
</loc>
<loc>
<locno>1</locno>
<bldno>2</bldno>
<PDSCov>
<PDSCLSCode>556456232323</PDSCLSCode>
</PDSCov>
</loc>
</locs>
<lbLocs>
<lbloc>
<locno>1</locno>
<bldno>1</bldno>
<Covs>
<Cov>
<CLSCode>2424434232323</CLSCode>
</Cov>
</Covs>
</lbloc>
<lbloc>
<locno>1</locno>
<bldno>2</bldno>
<Covs>
<Cov>
<CLSCode>555555</CLSCode>
</Cov>
</Covs>
</lbloc>
</lbLocs>
</root>
Output XML
<root>
<locs>
<loc>
<locno>1</locno>
<bldno>1</bldno>
</loc>
<loc>
<locno>1</locno>
<bldno>2</bldno>
</loc>
</locs>
<lbLocs>
<lbloc>
<locno>1</locno>
<bldno>1</bldno>
<Covs>
<Cov>
<CLSCode>2424434232323</CLSCode>
</Cov>
<Cov>
<CLSCode>232323</CLSCode>
</Cov>
</Covs>
</lbloc>
<lbloc>
<locno>1</locno>
<bldno>2</bldno>
<Covs>
<Cov>
<CLSCode>555555</CLSCode>
</Cov>
<Cov>
<CLSCode>556456232323</CLSCode>
</Cov>
</Covs>
</lbloc>
</lbLocs>
</root>
I need the nodes from one node moved into another.
How do I do this?
Thanks?
Alan
Alan Andrade | alan.andrade@insurity.com
The information contained in this e-mail message is intended only for the
personal and confidential use of the recipient(s) named above. This message
may be an attorney-client communication and/or work product and as such is
privileged and confidential. If the reader of this message is not the
intended recipient or an agent responsible for delivering it to the
intended recipient, you are hereby notified that you have received this
document in error and that any review, dissemination, distribution, or
copying of this message is strictly prohibited. If you have received this
communication in error, please notify us immediately by e-mail, and delete
the original message.
The information contained in this e-mail message is intended only for the
personal and confidential use of the recipient(s) named above. This message
may be an attorney-client communication and/or work product and as such is
privileged and confidential. If the reader of this message is not the
intended recipient or an agent responsible for delivering it to the
intended recipient, you are hereby notified that you have received this
document in error and that any review, dissemination, distribution, or
copying of this message is strictly prohibited. If you have received this
communication in error, please notify us immediately by e-mail, and delete
the original message.
RE: can xalan transform 2 xml using one xslt?
Posted by Alan Andrade <al...@insurity.com>.
Here is my problem
XML Input
<root>
<locs>
<loc>
<locno>1</locno>
<bldno>1</bldno>
<PDSCov>
<PDSCLSCode>232323</PDSCLSCode>
</PDSCov>
</loc>
<loc>
<locno>1</locno>
<bldno>2</bldno>
<PDSCov>
<PDSCLSCode>556456232323</PDSCLSCode>
</PDSCov>
</loc>
</locs>
<lbLocs>
<lbloc>
<locno>1</locno>
<bldno>1</bldno>
<Covs>
<Cov>
<CLSCode>2424434232323</CLSCode>
</Cov>
</Covs>
</lbloc>
<lbloc>
<locno>1</locno>
<bldno>2</bldno>
<Covs>
<Cov>
<CLSCode>555555</CLSCode>
</Cov>
</Covs>
</lbloc>
</lbLocs>
</root>
Output XML
<root>
<locs>
<loc>
<locno>1</locno>
<bldno>1</bldno>
</loc>
<loc>
<locno>1</locno>
<bldno>2</bldno>
</loc>
</locs>
<lbLocs>
<lbloc>
<locno>1</locno>
<bldno>1</bldno>
<Covs>
<Cov>
<CLSCode>2424434232323</CLSCode>
</Cov>
<Cov>
<CLSCode>232323</CLSCode>
</Cov>
</Covs>
</lbloc>
<lbloc>
<locno>1</locno>
<bldno>2</bldno>
<Covs>
<Cov>
<CLSCode>555555</CLSCode>
</Cov>
<Cov>
<CLSCode>556456232323</CLSCode>
</Cov>
</Covs>
</lbloc>
</lbLocs>
</root>
I need the nodes from one node moved into another.
How do I do this?
Thanks'
Alan
Alan Andrade | alan.andrade@insurity.com
<ma...@insurity.com>
________________________________
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above. This
message may be an attorney-client communication and/or work product and
as such is privileged and confidential. If the reader of this message is
not the intended recipient or an agent responsible for delivering it to
the intended recipient, you are hereby notified that you have received
this document in error and that any review, dissemination, distribution,
or copying of this message is strictly prohibited. If you have received
this communication in error, please notify us immediately by e-mail, and
delete the original message.
-----------------------------------------
The information contained in this e-mail message is intended only
for the personal and confidential use of the recipient(s) named
above. This message may be an attorney-client communication and/or
work product and as such is privileged and confidential. If the
reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are
hereby notified that you have received this document in error and
that any review, dissemination, distribution, or copying of this
message is strictly prohibited. If you have received this
communication in error, please notify us immediately by e-mail, and
delete the original message.
Re: can xalan transform 2 xml using one xslt?
Posted by ke...@us.ibm.com.
Use the XSLT document() function to access the second source file, then
write your transform to retrieve the needed data from both.
______________________________________
"... Three things see no end: A loop with exit code done wr ng,
A semaphore untested, And the change that comes along. ..."
-- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)