XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + how to insert un return in the... (2)
-> + String in a range (5)
-> + To identify the right edition (4)
-> + Flow Control Feature (2)
-> + calling nested external functi... (3)
-> + Replacing commas with a blank (6)
-> + Grouping very urgent . (2)
-> + xsl node number (3)
-> + Wordml intelligence (6)
-> + Preview and backmapping for wo... (5)
-> + XSLT - find line numbers of di... (2)
-> + The last five bytes of a varia... (7)
-> + simple problem but i'm a bit t... (3)
-> + H plz help me (2)
-> + XSLT : Very Urgent Requirement (7)
-> + comparing two xml files (3)
-> + Support for xsl created from w... (4)
-> + Wildcard Param (3)
-> + XSLT OutOfMemoryError (3)
-> + How can I output the filename ... (7)
-> + How do I strip out a comma ast... (8)
-> + xslt current-dateTime() not re... (2)
-> + Exceed the maximum recursion d... (8)
-> + Saxon9 "java.net.ConnectExcept... (2)
-> - Help Required (1)
-> + XSLT Help to get value from Up... (2)
-> + Date Functions (5)
-> + Need to unescape < and > (2)
-> + No Topic (2)
-> + Problem with handling multiple... (3)
-> + Question XPath expression (dis... (2)
-> + New user, basic question (2)
-> + Serializing XML to a string wi... (2)
-> + Node already has a control li... (2)
-> + Trying to access the position ... (5)
-> + XSLT Help (2)
-> - XSLT, Microsoft Access, and re... (4)
-> ->XSLT, Microsoft Access, a...
-> ->XSLT, Microsoft Access, a...
-> ->XSLT, Microsoft Access, a...
-> + saxon:assign usage problem. (5)
-> + Help with XSLT mapping require... (4)
-> + Muenchian Grouping problem (6)
-> + Automatic postprocessing (2)
-> + Problem Setting Variable (3)
-> - Problem Setting Variable (1)
-> + Looping question (14)
-> + Attribute Centeric XML from Re... (2)
-> + How do I do this ? (2)
-> + Accessing an attribute based o... (3)
-> + help needed - using saxon thro... (2)
-> + Grouping Problem still (6)
-> + Use XSL-FO to create tables fr... (6)
-> + taking out a child and (6)
-> + Yet another problem (3)
-> + using XSL-FO to convert PDF (4)
-> + Preventing namespace declarati... (2)
-> + Small problem during conversio... (4)
-> + Problems removing namespaces (2)
-> + Grouping/Following question (4)
-> + Transforming XML into another ... (3)
-> + Help Needes (3)
-> - Help needed! (1)
-> + Conv of DSML Format to XML for... (2)
-> - Regd, entering text in the t... (1)
-> + displaying all the text around... (4)
-> + inserting values into empty ta... (5)
-> + How to get rid of xmlns="" att... (3)
-> + XSLT How to include the '<' sy... (2)
-> - HELP: Functional XSLT Implemen... (1)
-> - Cannot find a matching 1-argum... (1)
-> + XSLT a:? (2)
-> + Attribute Value Concatenation (2)
-> - Why is the WYSIWYG xslt editor... (1)
-> + WebService Call Error: Ref ele... (4)
-> + How to replace value of a fiel... (2)
-> + Schema Validation Problems (3)
-> + Reusing a prior valid value in... (5)
-> + Clutching at straws! (2)
-> + Adding a number to a for each ... (2)
-> + Transform Name Value pairs int... (4)
-> + Transform the XML Scheme with ... (2)
-> + create XML drop down lists (2)
-> + error during stylesheet tutori... (3)
-> + Modify the value in a element ... (2)
-> + Call to extension function fai... (2)
-> + Convert XML Schema to XML - Mi... (2)
-> + How to calculate maximun RowCo... (3)
-> + Help with using not(preceding:... (5)
-> - Please Help me on this XML to ... (1)
-> + Paasing Parameter Values From ... (6)
-> + XSLT Transformation w/ namespa... (3)
-> + For-each select and parameter ... (3)
-> + Using < (less than) operator (5)
-> + Inserting carriage return (spe... (3)
-> + Inserting carriage return (spe... (2)
-> + Help with SerializerTrace erro... (8)
-> + xml to x3d (5)
-> + Exiting processing loop early (2)
-> + Easy way to Convert One source... (3)
-> + XSLT Editor tab missing from D... (2)
-> + Writing strings of characters ... (4)
-> + Adding the content of an eleme... (3)
-- Previous [601-620] [621-640] [641-660] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
Craig BermanSubject: XSLT, Microsoft Access, and repeating data
Author: Craig Berman
Date: 25 Apr 2008 10:49 AM
Our company is new to Stylus, but we know we need something as too many outside providers are using XML. So, that being said, I hope this question does not taint us as "Buy the XML for Dummies" folks.

We are using the "Mapper" function to create an XSLT to convert a file from XML to be usable in Microsoft Access (First step work here). We've hit the following construct:

<ShortNotes>
<ShortNote>
<Index>1</Index>
<Text>AE=X4H</Text>
</ShortNote>
<ShortNote>
<Index>2</Index>
<Text>US912828HV51</Text>
</ShortNote>
<ShortNote>
<Index>4</Index>
<Text>A#1972767790</Text>
</ShortNote>
</ShortNotes>

The value of index can be 1-8.

The access database has the fields SN1, SN2,.... SN8. What we want to do is have the fields populated based upon the index. If I were writing this in some programming language it would be:

If Index = 1 then SN1= <Text> else
If Index = 2 then SN2 = <Text> else ...... etc

I'm sure that this can be done using XSLT, its just that we are too "green" to have tackled the various constructs. Or perhaps, we simply can't figure out how to do this in the Mapper, but it could be done with putting the propper commands in the XSLT with an editor.

Either way, thanks for any help, and apologies in advance if this question just shows we need to hire some XML gurus around here.

Postnext
(Deleted User) Subject: XSLT, Microsoft Access, and repeating data
Author: (Deleted User)
Date: 29 Apr 2008 06:11 AM
You could create the stylesheet using Mapper, but it would be an overly complex stylesheet (with a lot of xsl:choose to send the data to the correct target element). A smaller stylesheet that should work for you is this one:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<root>
<xsl:apply-templates select="ShortNotes/ShortNote"/>
</root>
</xsl:template>


<xsl:template match="ShortNote">
<xsl:element name="SN{Index}">
<xsl:value-of select="Text"/>
</xsl:element>
</xsl:template>

</xsl:stylesheet>

Hope this helps,
Alberto

Postnext
Craig BermanSubject: XSLT, Microsoft Access, and repeating data
Author: Craig Berman
Date: 29 Apr 2008 02:01 PM
Many Many Thanks, I should have been more specific, as this form of construct is very normal from the vendor we receive this data. Here is a piece of the raw data:

<?xml version="1.0" encoding="UTF-8"?>
<BatchFeed xmlns="urn:tradefeed-xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<TradeFeed>
<Common>
<BloombergFirmID>XXXX</BloombergFirmID>
<TransactionNumber>9XXXXX</TransactionNumber>
<SecurityIdentifierFlag>1</SecurityIdentifierFlag>
<SecurityIdentifier>123456785</SecurityIdentifier>
<ShortNotes>
<ShortNote>
<Index>1</Index>
<Text>AE=XYZ</Text>
</ShortNote>
<ShortNote>
<Index>2</Index>
<Text>123456789000</Text>
</ShortNote>
<ShortNote>
<Index>4</Index>
<Text>A#1234567890</Text>
</ShortNote>
</ShortNotes>
<TraderAccountName>12345678</TraderAccountName>
<SalespersonName>XYZ</SalespersonName>
</Common>
</TradeFeed>
</BatchFeed>

The tags <TradeFeed></TradeFeed> repeat for each trade in the file.

Here is a piece of XSL from mapper that does nothing more than create an access table called "TheCommon", with 2 fields - "Firm" and "Trade"... no biggie....

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:tradefeed-xsd">
<xsl:template match="/">
<TheTrade>
<xsl:for-each select="a:BatchFeed/a:TradeFeed">
<TheCommon>
<Firm>
<xsl:value-of select="a:Common/a:BloombergFirmID"/>
</Firm>
<Trade>
<xsl:value-of select="a:Common/a:TransactionNumber"/>
</Trade>
</TheCommon>
</xsl:for-each>
</TheTrade>
</xsl:template>
</xsl:stylesheet>

It works fine... but what I want is to create an access table called "TheCommon" with 10 fields... "Firm", "Trade", and "SN1"..."SN8", representing ShortNotes by Index.

You gave me the piece of XSL:

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<root>
<xsl:apply-templates select="ShortNotes/ShortNote"/>
</root>
</xsl:template>


<xsl:template match="ShortNote">
<xsl:element name="SN{Index}">
<xsl:value-of select="Text"/>
</xsl:element>
</xsl:template>

</xsl:stylesheet>


My question is, given the For-Each construction looping through <TradeFeed>, where and how do I fit this into the simple XSL above? This will cover about 90% of the problem for me, and maybe even get us on the way to processing one of these files.

Many Thanks

Posttop
(Deleted User) Subject: XSLT, Microsoft Access, and repeating data
Author: (Deleted User)
Date: 02 May 2008 10:39 AM
Hi Craig,
simply copy the template in your stylesheet and add the <xsl:apply-templates select="ShortNotes/ShortNote"/> after the </Trade> element in your stylesheet

Alberto

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.