Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Access Database to XML - format

Status
Not open for further replies.

JeffNolan1900

Technical User
Mar 21, 2007
26
0
0
US
Hello.
I have an Access Database, like this.

Name Color Body_Type Age
-------------------------------------------
Dog Red Fat Old
Cat Yellow Skinny Young

Using Access to create the XML file from the data. And Using Tranform, I need to specify the xml template.
I need a tranform (.xslt) file that will result in this format:

<Feature Name="Dog" Color="Red">
<Symbology>
<Body Type>Fat</Body Type>
<Age>Old</Age>
</Symbology>
</Feature>
<Feature Name="Cat" Color="Yellow">
<Symbology>
<Body Type>Skinny</Body Type>
<Age>Young</Age>
</Symbology>
</Feature>

---------------------------------
The Body Type and Age are easy.
<Body Type><xls:value-of select="Body_type"></Body Type>
---------------------------------
The Feature Name and Color is where the problems start.
<Feature Name="<xls:value-of select="Name">" Color="<xls:value-of select="Color">">

I know this is the wrong format, but I just provided it as an example. What is the proper format for something like this? Any suggestions on how to do this?
---------------------------------

Thanks so much.
Jeff
 
Thanks,
So I would use something like this:
<feature>
<xsl:attribute name="Name">
<xsl:value-of select="Name" />
</xsl:attribute>
<xsl:attribute name="Color">
<xsl:value-of select="Color" />
</xsl:attribute>
</feature>

Which would result in:
<feature Name="Dog" Color="Red">
<feature Name="Cat" Color="Yellow">
 
That is correct.

Now, there is another 'shortcut' way to do the same thing in many circumstances (including yours), called Attribute Value Template. You can learn about this technique in this tutorial.

Tom Morrison
 
Ok. Got it working.

Is there a way to append text to an attribute?

What I mean is this:
If the Database "Name" value is "Dog"
How do I add _Text to the end of Dog?

Before I hit Submit, I figured it out, so in case anyone is ever reading this, who does not know...here is the answer:

xsl with append text to xsl:value-of
<feature>
<xsl:attribute name="name">
<xsl:value-of select="concat(Name,'_Text')" />
</xsl:attribute>
<xsl:attribute name="color">
<xsl:value-of select="Color" />
</xsl:attribute>
</feature>

xml output
<feature name="Dog_Text" color="Red">



 
How can I get it to read a query from an external database?

For instance, this query is called: Graphic_Report

So I use this:
<xsl:for-each select="DogCat_Report">

What if I had a seperate database that had additional properties that I wanted to pull in.
For instance in the file OtherAnimas.mdb
Query: Birds_Report

How do I call this other database?
I really hope this is possible...
 
I have an Access database that looks like this:

nc:Name nc:ID nc:Score

I need the XML output tags to reflect the colon and NOT _003A_ in its place.

I am simply exporting the data from MS Access and selecting XML as my file type. The result is the _003A_ in place of the colon.

Can someone help? I admit this is beyond me but I am a fast learner and need to turn this file around asap.

Thank you.

Heather
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top