StructuredXml type provider error

29 views
Skip to first unread message

Christopher Atkins

unread,
Oct 12, 2012, 9:37:41 AM10/12/12
to fsh...@googlegroups.com
Can anyone help with this?

This code:

type Project = StructuredXml<"project.xml">

...

    let projectDocument = Project(filename="project.xml")

    let projectNode = projectDocument.Root.GetProjects() |> Seq.head

    let title = projectNode.GetTitles() |> Seq.head


Produces this error:
Error 5 A reference to the type 'FSharpx.StructuredXml,FileName="project.xml".Title' in assembly 'FSharpx.TypeProviders.Documents' was found, but the type could not be found in that assembly C:\Code\Imposition\Inku2Sml\Program.fs 16 17 Inku2Sml

Steffen Forkmann

unread,
Oct 12, 2012, 9:43:05 AM10/12/12
to fsh...@googlegroups.com
can you send me the project.xml file (or maybe a smaller version which reproduces)?

2012/10/12 Christopher Atkins <christo...@gmail.com>

Christopher Atkins

unread,
Oct 12, 2012, 10:24:54 AM10/12/12
to fsh...@googlegroups.com
I spent some time paring this down to a simpler document that still exhibits the problem.  It seems the <Title/> at two different places is the problem.

<OrderContainer>

  <Backgrounds >

    <Background>

      <Title>Purple Stars</Title>

    </Background>

  </Backgrounds>

  <Project >

    <Title>Avery</Title>

  </Project>

</OrderContainer>

Steffen Forkmann

unread,
Oct 12, 2012, 12:17:24 PM10/12/12
to fsh...@googlegroups.com

Thanks. I'll try to fix this

Tomas Petricek

unread,
Oct 12, 2012, 10:41:14 PM10/12/12
to fsh...@googlegroups.com

Hmm, yes, this is a limiatation of the type provider.

 

It does not unify elements that appear repeatedly in a different part of the structure. I’m not entirely sure what is the best thing to do – it could either treat them as different (and just add some index to avoid the name clash) or perhaps it should unify them (which would make good sense i.e. for HTML-like documents).

 

T.

 

Steffen Forkmann

unread,
Oct 13, 2012, 6:52:28 AM10/13/12
to fsh...@googlegroups.com
Hi,

for now I fixed it by adding a suffix to the generated type. I also tried to encode the path in the type but somehow this did not work. Very strange.
@tomas: Yes, unification would be cool, but I have no time for this at the moment,

I fixed it for XML and JSON and added a couple of tests: https://github.com/fsharp/fsharpx/commit/6930187e60b7652e27274ddcadcc3ac199c4b2c0

Please try FSharpx.TypeProviders 1.6.85 

Cheers,
Steffen

2012/10/13 Tomas Petricek <to...@tomasp.net>

Christopher Atkins

unread,
Oct 15, 2012, 7:47:46 PM10/15/12
to fsh...@googlegroups.com
I wanted to write a quick note of gratitude.  This works great, as I'm sure you expected, thanks.

In the future I will try to submit pull requests.
Reply all
Reply to author
Forward
0 new messages