Skip to main content
Solved

converting excel file into XSD fomat?

  • June 17, 2020
  • 6 replies
  • 453 views

Forum|alt.badge.img

Hi,

I am looking for learning the way we can convert excel files into XSD format. Any basic tutorials/videos that can help me to learn this quickly?

Regards,

Purvi

Best answer by jdh

As far as I am aware there isn't an automatic xsd writer.

 

 

xsd however is just XML, so you could use an XMLTemplater to construct the relevant data.

 

 

Something along the lines of

Root (Creator):

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="https://www.w3schools.com"

xmlns="https://www.w3schools.com"

elementFormDefault="qualified">

<xs:sequence>

{fme:process-features("SUB")}

</xs:sequence>

</xs:schema>

 

 

SUB (your excel data):

 

<xs:element name="{fme:get-attribute("Field")}" type="{fme:get-attribute("Type")}"/>

 

Where type is generally one of

  • xs:string
  • xs:decimal
  • xs:integer
  • xs:boolean
  • xs:date
  • xs:time

so you may need to restructure your excel data (AttributeValueMapper)

If you have a nested data structure then you need to use complex elements, and will probably require multiple subtemplates.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • June 17, 2020

Is your excel file a schema description or data?

FieldTypeIDIntNAMEString (50)

 

 

vs

IDNAME1John Doe2Jane Smith

Forum|alt.badge.img
  • Author
  • 27 replies
  • June 17, 2020

Is your excel file a schema description or data?

FieldTypeIDIntNAMEString (50)

 

 

vs

IDNAME1John Doe2Jane Smith

Hi @jdh, Yes that excel file is a schema at the moment.

Regards,


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • Best Answer
  • June 17, 2020

As far as I am aware there isn't an automatic xsd writer.

 

 

xsd however is just XML, so you could use an XMLTemplater to construct the relevant data.

 

 

Something along the lines of

Root (Creator):

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="https://www.w3schools.com"

xmlns="https://www.w3schools.com"

elementFormDefault="qualified">

<xs:sequence>

{fme:process-features("SUB")}

</xs:sequence>

</xs:schema>

 

 

SUB (your excel data):

 

<xs:element name="{fme:get-attribute("Field")}" type="{fme:get-attribute("Type")}"/>

 

Where type is generally one of

  • xs:string
  • xs:decimal
  • xs:integer
  • xs:boolean
  • xs:date
  • xs:time

so you may need to restructure your excel data (AttributeValueMapper)

If you have a nested data structure then you need to use complex elements, and will probably require multiple subtemplates.


Forum|alt.badge.img
  • Author
  • 27 replies
  • June 17, 2020

As far as I am aware there isn't an automatic xsd writer.

 

 

xsd however is just XML, so you could use an XMLTemplater to construct the relevant data.

 

 

Something along the lines of

Root (Creator):

<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace="https://www.w3schools.com"

xmlns="https://www.w3schools.com"

elementFormDefault="qualified">

<xs:sequence>

{fme:process-features("SUB")}

</xs:sequence>

</xs:schema>

 

 

SUB (your excel data):

 

<xs:element name="{fme:get-attribute("Field")}" type="{fme:get-attribute("Type")}"/>

 

Where type is generally one of

  • xs:string
  • xs:decimal
  • xs:integer
  • xs:boolean
  • xs:date
  • xs:time

so you may need to restructure your excel data (AttributeValueMapper)

If you have a nested data structure then you need to use complex elements, and will probably require multiple subtemplates.

Thanks @jdh for your detailed answer. Do you have any workbench example template or tutorial to follow through this?

As I am really new to understand/create XML and XSD file format.

Regards,

Purvi


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • June 18, 2020

Thanks @jdh for your detailed answer. Do you have any workbench example template or tutorial to follow through this?

As I am really new to understand/create XML and XSD file format.

Regards,

Purvi

I've actually never written an xsd file. I would start with w3schools for an overview of the format. https://www.w3schools.com/xml/schema_intro.asp

 

For creating it in FME check out https://knowledge.safe.com/articles/30940/xml-writing-with-xmltemplater.html


Forum|alt.badge.img
  • Author
  • 27 replies
  • June 18, 2020

I've actually never written an xsd file. I would start with w3schools for an overview of the format. https://www.w3schools.com/xml/schema_intro.asp

 

For creating it in FME check out https://knowledge.safe.com/articles/30940/xml-writing-with-xmltemplater.html

Thanks @jdh, I will follow through this link to work on this... :)

Regards,