RobertGeoff
asked on
xslt problem
Hello-
I am trying to develop an xslt engine. However, when I put the raw xml file into the engine, the output is the original/complete xml file. I was trying to only extract certain data from the original xml file. The code is below
Do you have any solution, or is there a problem with my code? Thank you. Robert
I am trying to develop an xslt engine. However, when I put the raw xml file into the engine, the output is the original/complete xml file. I was trying to only extract certain data from the original xml file. The code is below
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:err="http://www.w3.org/2005/xqt-errors"
exclude-result-prefixes="xs xdt err fn">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="invention-title"></xsl:value-of>
<xsl:value-of select="abstract"></xsl:value-of>
<xsl:value-of select="us-parties/us-applicants/us-applicant"></xsl:value-of>
<xsl:value-of select="us-parties/inventors/inventor"></xsl:value-of>
<xsl:value-of select="us-exemplary-claim"></xsl:value-of>
<xsl:value-of select="us-bibliographic-data-grant/application-reference"></xsl:value-of>
<xsl:value-of select="us-term-of-grant/us-term-of-extension"></xsl:value-of>
<xsl:value-of select="classifications-ipcr/classification-ipcr/section"></xsl:value-of>
<xsl:value-of select="classifications-ipcr/classification-ipcr/class"></xsl:value-of>
<xsl:value-of select="classifications-ipcr/classification-ipcr/subclass"></xsl:value-of>
<xsl:value-of select="classifications-ipcr/classification-ipcr/main-group"></xsl:value-of>
<xsl:value-of select="classifications-ipcr/classification-ipcr/subgroup"></xsl:value-of>
<xsl:value-of select="classification-national/main-classification"></xsl:value-of>
<xsl:value-of select="classification-national/further-classification"></xsl:value-of>
<xsl:value-of select="us-field-of-classification-search/classification-national/main-classification"></xsl:value-of>
<xsl:value-of select="drawings/figure"></xsl:value-of>
</xsl:template>
</xsl:stylesheet>
Do you have any solution, or is there a problem with my code? Thank you. Robert
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK great
ASKER
Gertone-
As you're an xslt expert, you can help me out with one other thing. Let me know if I need to formerly post.
I'll incorpoate my xslt engine into a vb(2010) application. The xslt engine will be located at a specific url. this will allow me to distibute the application only.
do you have any sample code handy? i'll start to code later today, but having a good reference is useful. robert
As you're an xslt expert, you can help me out with one other thing. Let me know if I need to formerly post.
I'll incorpoate my xslt engine into a vb(2010) application. The xslt engine will be located at a specific url. this will allow me to distibute the application only.
do you have any sample code handy? i'll start to code later today, but having a good reference is useful. robert
Hi Robert,
There are some things you need to be aware of.
VB.net does not natvely support XSLT2
so this
<xsl:stylesheet version="2.0"
should be
<xsl:stylesheet version="1.0"
and there are a bunch of functions you then can not use
(likely you don't use them)
I am not a VB.net coder, so basicaly I have no clue how to call an XSLT from a VB.net application
but I usually look around...
maybe this would help
http://stackoverflow.com/questions/1187782/vb-net-apply-xsl-transformation-to-xml-file
There are some things you need to be aware of.
VB.net does not natvely support XSLT2
so this
<xsl:stylesheet version="2.0"
should be
<xsl:stylesheet version="1.0"
and there are a bunch of functions you then can not use
(likely you don't use them)
I am not a VB.net coder, so basicaly I have no clue how to call an XSLT from a VB.net application
but I usually look around...
maybe this would help
http://stackoverflow.com/questions/1187782/vb-net-apply-xsl-transformation-to-xml-file
ASKER
Thanks. That little bit about "1.0" and "2.0" was a big time saver. RD
welcome
ASKER
Gertone-
FYI, My final code is below. You may find it useful in the future. But, I am trouble accessing the XSL from an online server. I have tried putting in DROPLR, but I keep getting an error message. Right now, I stuck it on Google, but I'm not sure if this will work. Do you know of a suitable way to store an XSL file on an online server for access by an application? Thanks. Robert
FYI, My final code is below. You may find it useful in the future. But, I am trouble accessing the XSL from an online server. I have tried putting in DROPLR, but I keep getting an error message. Right now, I stuck it on Google, but I'm not sure if this will work. Do you know of a suitable way to store an XSL file on an online server for access by an application? Thanks. Robert
Public Class XSLTform
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim document As XmlDocument
Dim savefileDialog1 As New SaveFileDialog()
Dim output As StringWriter
Dim navigator As XPathNavigator
document = New XmlDocument()
document.LoadXml(textbox1.Text)
'load the stylesheet
Dim xslt As New XslCompiledTransform()
xslt.Load("C:\Users\RobertGeoff\Pictures\Patent Pie docs and programs\PatentXSLT.xsl")
'execute the transformation and output results to a file
xslt.Transform(textbox1.Text, "Save.Text")
output = New StringWriter()
navigator = document.CreateNavigator
xslt.Transform(navigator, Nothing, output)
Dim stream As FileStream = _
New FileStream(savetxt.Text, FileMode.Create)
Dim writer As StreamWriter = New StreamWriter(stream)
writer.Write(output.ToString)
' close streams
writer.Close()
output.Close()
'upon pressing the transformation button, a dialog to save the file should come up- Cf the savefiledialog sub down below.
savefileDialog1.ShowDialog()
savefileDialog1.Title = "Select or Enter Filename"
savefileDialog1.Filter = "xml Files(*.xml)|*.xml|All Files|*,*"
savefileDialog1.FilterIndex = 1
savefileDialog1.RestoreDirectory = True
End Sub
it all depends on the .net mechanism of resolving the url in the load
it might be that you need to deactivate some security settings
I am afraid this really is a VB.net issue and I recommend that you post a question in the VB.net TA
it might be that you need to deactivate some security settings
I am afraid this really is a VB.net issue and I recommend that you post a question in the VB.net TA
ASKER