[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: More newbie questions

Subject: RE: More newbie questions
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Tue, 22 Mar 2005 09:18:17 +0200
bloodshed comma separated value
Hi,

> Here is a sample of some XML I need to deal with:
>
> <Root>
> <Database DatabaseName="2004DATA" />
> <Response>
> 	<Record number="1">
> 		<Field FieldName="DOCID">SAP1234</Field>
> 		<Field FieldName="COUNTRY">USA</Field>
> 		<Field FieldName="CITY">Baltimore</Field>
> 		<Field FieldName="TEXT">Baltimore is a
> &lt;b&gt;big&lt;/b&gt; city...</Field>
> 	</Record>
> 	<Record number="2">
> 		<Field FieldName="DOCID">XYZ4433</Field>
> 		<Field FieldName="COUNTRY">Canada</Field>
> 		<Field FieldName="CITY">Toronto, Montreal</Field>
> 		<Field FieldName="TEXT">Toronto and Montreal are in
> Canada</Field>
> 	</Record>
> 	<Record number="3">
> 		<Field FieldName="DOCID">ABC123</Field>
> 		<Field FieldName="COUNTRY">Sweden</Field>
> 		<Field FieldName="CITY">Stockholm</Field>
> 		<Field FieldName="TEXT">Stockholm is a
> &lt;b&gt;big&lt;/b&gt; city also...</Field>
> 	</Record>
> <Response>
> </Root>
>
> 1- My first issue concerns the Database tag. As you can
> see, I receive an XML response with 1 response and
> multiple Records nested within it. I need to
> extract each "Record" and transform it to be different
> XML (no attribute names for one thing...), and I need
> to add the value in the Database tag (2004DATA) to each
> "Record" before inserting the doc as a CLOB into a
> database. The problem is, my limited xsl skills have
> allowed me to extract the data I need, but I can't
> figure out how to get the database name value into each
> record. I tried assigning the value to a variable with

If the current node is Record, then e.g. "../../Database/@DatabaseName" will
give you the database name.

> xsl:variable, but the transformation fails. Any help
> appreciated...
>
> 2- How would I create multiple CITY tags in the output

With XSLT you don't create "tags in the output", you create a node tree and
then you can serialize that to XML tags.

> when faced with a response like that in record # 2,
> where the value is Toronto, Montreal?  I don't want a
> comma separated value in the body of the tag.

Write a recursive template that tokenizes the stream using COMMA as a
delimiter. See the FAQ, e.g.
<http://www.dpawson.co.uk/xsl/sect2/N7240.html#d9086e280>

> 3- You may have noticed the escaped angle brackets for
> the HTML tags in the TEXT tag value. How do I have them
> display properly? I played with the output="html" and
> the escape attribute to no avail.

See the FAQ again, <http://www.dpawson.co.uk/xsl/sect2/N2215.html>.

Cheers,

Jarno - Hocico: Bloodshed

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.