|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Flattening XML with XSL
I just started using XSL this morning to try to solve a problem I am having reading XML into Access. I am somewhat familiar with Access, pretty new to XML, and very new to XSL.
The problem is that when I read the XML file into Access, it gets separated into several different, unlinked tables. I've learned that you can write a transform in XSL to "flatten" the table from the Microsoft site. The problem I am having is that when reading in information about a person, they often have a home telephone and a business telephone (XML is being generated elsewhere), so the person could have two telephone numbers in their record. The XML for the phone number is the same regardless of the phone type, and I can't get the XSL transformed output to show both. Even showing as a second record with being able to somehow being able to specificy in a field that the names are the same would be okay. Does this make sense? Any help would be appreciated. Thanks, Frank |
|
#2
|
|||
|
|||
|
can you paste a XML node that would equate to a row in your database.
|
|
#3
|
|||
|
|||
|
Don't know if this is "node" information or not - sorry I am not more familiar with the terminology.
Layer 1 <RECORDNO> <ADDRESS> </ADDRESS> <PHONE> </PHONE> </RECORDNO> Layer 2 <PHONE> <phone_type> HM </phone_type> <phone_number> 1234567891 </phone_number> </PHONE> <PHONE> <phone_type> OT </phone_type> <phone_number> 5555555555 </phone_number> </PHONE> What I was trying to do originally was have to have the database show RECORD NO (some attributes like date created) ADDRESS (address, city ,etc) PHONE (phone_type, number) all in one record When the XML file is read into Access now, everything goes in its own table RECORDNO, ADDRESS, PHONE etc. with no links among them and now way to rebuild the heirarchy from what I can tell. I was told to try to transform the file using XSLT (?), which have attempted with some effort. I discovered that the data contains more than phone_type, so when I do the transformation, I'll get everything in one record, but it will only pick up one of the phone types. Since I don't explicity know how many phone types there might be, it figured that I ought to put them in a separate table anyway as future XML files might not be imported properly. Which is to say I am now looking to see in Access: Table 1: RECORDNO (attributes) ADDRESS (attributes) Table 2: RECORDNO (recordID only as primary key) PHONE (attributes) What I can't figure out is how to go "up" a level to attach recordID to the PHONE information in XSL. I have attached the XSL code, which I have copied/learned from the Microsoft site. When I run it I get the current one PHONE per record result. Any hints would be greatly appreciated. Thanks! |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Flattening XML with XSL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|