Register
Login
Search
Forum
Home
Products
Downloads
Forum
Learn
Forum
Search
Forum Home
Mvp.Xml Project
XInclude.NET
Xpointer and In...
Xpointer and Indentation
moonty
2 posts
Joined
10/6/2006
Xpointer and Indentation
Posted: 06 Oct 06 1:45 AM (United Kingdom)
I have an xinclude statement that is throwing an error/fallback when I add a xpointer statement. After playing around for a while I formatted the XML the xinclude was referencing and then it worked, however when I removed all the spacing/indentation again the error/fallback came back.
Has anyone else experienced this?
Thanks,
Josh
olegt
85 posts
www.xmllab.net
Joined
2/25/2005
Re: Xpointer and Indentation
Posted: 08 Oct 06 6:41 AM (Israel)
That sounds weird. Can you show your XPointer statement and sample XML so I could reproduce the problem?
Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net
|
http://blog.tkachenko.com
moonty
2 posts
Joined
10/6/2006
Re: Xpointer and Indentation
Posted: 10 Oct 06 4:06 AM (United Kingdom)
FileA.xml
-----------------
<?xml version="1.0" encoding="utf-8" ?>
<Root xmlns:xi="http://www.w3.org/2003/XInclude">
<xi:include href="FileB.xml" xpointer="xpointer(//NodeA)"><xi:fallback>Error</xi:fallback></xi:include>
</Root>
-----------------
Transform.xsl
-----------------
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>
-----------------
Default.vb
-----------------
Imports System.Web
Imports System.Xml
Imports System.Xml.Schema
Imports System.Xml.Xsl
Imports System.Xml.XPath
Imports System.Net
Imports System.IO
Imports System.Text
Imports System.Configuration
Imports Mvp.Xml.Common
Imports Mvp.Xml.Common.Xsl
Imports Mvp.Xml.Exslt
Imports Mvp.Xml.XInclude
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim xslFileLocation As String = Server.MapPath("Transform.xsl")
Dim xmlXPathDoc As String = Server.MapPath("FileA.xml")
Dim stringW As New StringWriter
Dim xInput As XmlInput
Dim xInputReader As XIncludingReader = Nothing
Dim xOutput As XmlOutput
Dim reader As XmlReader = Nothing
Dim xsltSettings As New XsltSettings
Dim resolver As New XmlUrlResolver()
Dim settings As New XmlReaderSettings()
Try
' Create XsltCommand and compile stylesheet.
Dim processor As MvpXslTransform = Nothing
resolver.Credentials = CredentialCache.DefaultCredentials
xsltSettings.EnableDocumentFunction = True
settings.ProhibitDtd = False
reader = XmlReader.Create(xslFileLocation, settings)
processor = New MvpXslTransform(False)
processor.Load(reader, xsltSettings, resolver)
xInputReader = New XIncludingReader(xmlXPathDoc)
xInputReader.XmlResolver = New XMLBase
Dim xInputDoc As New XmlDocument
xInputDoc.Load(xInputReader)
xInput = New XmlInput(xInputDoc)
xOutput = New XmlOutput(stringW)
processor.Transform(xInput, Nothing, xOutput)
processor.TemporaryFiles.Delete()
processor = Nothing
Catch ex As Exception
Response.Write(ex.Message)
Finally
reader.Close()
xInputReader.Close()
End Try
Response.Write(stringW.ToString)
End Sub
End Class
Public Class XMLBase
Inherits System.Xml.XmlUrlResolver
Public Overrides Function ResolveUri(ByVal baseUri As System.Uri, ByVal relativeUri As String) As System.Uri
Return MyBase.ResolveUri(baseUri, HttpContext.Current.Server.MapPath("/") & relativeUri)
End Function
End Class
-----------------
FileB.xml (compressed)
-----------------
<?xml version="1.0" encoding="utf-8" ?><Root><NodeA>NodeA Content</NodeA><NodeB>NodeB Content</NodeB></Root>
-----------------
Result: Error
FileB.xml (formatted)
-----------------
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<NodeA>NodeA Content</NodeA>
<NodeB>NodeB Content</NodeB>
</Root>
-----------------
Result: NodeA Content
olegt
85 posts
www.xmllab.net
Joined
2/25/2005
Re: Xpointer and Indentation
Posted: 21 Jun 07 2:11 AM (Israel)
Sorry, cannot reproduce the problem. Works for me no matter indented or not if FileB.xml.
Oleg Tkachenko, Microsoft MVP for XML, MCPD
http://www.XmlLab.Net
|
http://blog.tkachenko.com
Page 1 of 1
Mvp.Xml Project
XInclude.NET
Xpointer and In...
Flat View
Tree View
Oldest To Newest
Newest To Oldest
Forum Home
Search
Terms Of Use
Privacy Statement
©2005 Oleg Tkachenko