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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL in VFP

Status
Not open for further replies.

wgcs

Programmer
Mar 31, 2002
2,056
EC
I haven't had time to research this yet, but I see it coming:

In VFP, XMLTOCURSOR requires a specific XML schema. Is there a way to use XSL from within VFP to transform an XML document into the XML schema VFP needs?

(I'm not asking for the XSL... that is, of course, dependant on the XML I'm starting with... I'm just asking if anyone knows a way to apply an XSL from within VFP)
 
Answering my own questions again:

To apply an XSLT stylesheet to some XML, do this:

Code:
TEXT TO m.lcProtoXML NOSHOW
<?xml version="1.0" encoding="utf-8" ?>
<bookstore xmlns:bk="urn:samples">Bookstore Name
<book genre="novel" publicationdate="1997" bk:ISBN="1-861001-57-6">
	<title>Pride And Prejudice</title>
	<price>24.95</price>
</book>
<book genre="novel" publicationdate="1992" bk:ISBN="1-861001-45-3">
    <title>The New Dawn</title>    
    <price>29.95</price>    
</book>
<book genre="novel" publicationdate="1991" bk:ISBN="1-861001-57-8">
    <title>Blue Smoke</title>
    <price>19.95</price>
</book>
</bookstore>
ENDTEXT

TEXT TO m.lcXSLT NOSHOW
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="[URL unfurl="true"]http://www.w3.org/TR/WD-xsl">[/URL]
<xsl:template match="/">
<my-bookstore>
<xsl:for-each select="bookstore/book">
  <my-book>
    <my-books-title><xsl:value-of select="title"/></my-books-title>
    <my-books-price><xsl:value-of select="price"/></my-books-price>
  </my-book>
</xsl:for-each>
</my-bookstore>
</xsl:template>
</xsl:stylesheet>
ENDTEXT

loProtoXML = CREATEOBJECT('msxml2.DOMDocument')
loProtoXML.LoadXML( lcProtoXML )

loXSLT = CREATEOBJECT('msxml2.DOMDocument')
loXSLT.LoadXML( lcXSLT )

lcFinalXML = [<?xml version="1.0"?>] + loProtoXML.transformNode( loXSLT )

?lcFinalXML
 
wgcs

In order to use an XSL style sheet with an XML, all you need to do is make a reference to it in the header of the XML sheet.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top