I'm looking for a way to export table from excel to xml but every excel line should be different xml file, not as a default one xml file with all data.
So for example table like the one below:
This table should be exported into 3 xml files
first file 1.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<student-data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<TAGNAME1>mark</TAGNAME1>
<TAGNAME2>tom</TAGNAME2>
<TAGNAME3>london</TAGNAME3>
</record>
</student-data>
second file 2.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<student-data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<record>
<TAGNAME1>julie</TAGNAME1>
<TAGNAME2>jan</TAGNAME2>
<TAGNAME3>manchester</TAGNAME3>
</record>
</student-data>
etc...
Any ideas how to do that?
I've tried to use developer mode in excel with xml tab, but it export one file with all data.
Assuming you're using an XLSX file, you'll find it's actually a zip file. In its xl/worksheets subdirectory, the sheet1.xml and similarly named files (sheet2.xml, sheet3.xml, ...) represent the tabs that you see in the Excel file.
Typically, sheet1.xml will contain something like:
<worksheet...>
...
<sheetData>
<row r="1">
<c r="A1">...</c>
<c r="B1">...</c>
</row>
<row r="2">
<c r="A2">...</c>
<c r="B2">...</c>
</row>
</sheetData>
</worksheet>
Comparing that XML to what you see in Excel, you'll quickly spot the way a worksheet is encoded in XML. The <row><c/></row> structures almost immediately translate to what you need.
Strings are typically handled in a special way.
A cell with string contents usually contains a reference to a string value specified elsewhere. In the <c> element, the attribute t="s" indicates a referenced string. (the s attribute references a style id). The <v> element contains the string reference.
The zero-indexed reference list is stored in the xl/sharedStrings.xml file. Multiple occurrences of the same string will be stored more efficiently this way (instead of keeping them inline in the cells, which could result in multiple duplicates of the same string).
Using xmlstarlet and/or XSLT combined with some BaSH scripting for loops and handling file input and output, you could then get your desired result.
This is not an instant answer to what you want, but instead a nudge in the direction you could go. Your choice of tooling may vary. You'll learn useful things along the way. Learning curves may be steep but rewarding eventually. In the end, this will probably teach you more than any precooked answer.
Related
The OOXML specification says that an SpreadsheetML cell may have a string stored in the shared strings area, or may be a Rich Text Inline element, like this:
<row r="1" spans="1:1">
<c r="A1" t="inlineStr">
<is><t>This is inline string example</t></is>
</c>
</row>
Every test I've been doing with Excel puts strings in the shared strings area, even if they contain inter-cell formatting.
Does Excel ever create files that use the Rich Text Inline feature?
I tried on Microsoft Excel and LibreOffice, it's not possible to create Rich Text Inline strings with these applications. It appears the InlineStrings feature is supported only for the Open XML SDK.
It's possible to generate an Open XML document with the SDK that contains Inline Strings and Microsoft Excel and LibreOffice can open these documents successfully.
However if the file is edited in these applications, the file is updated and the InlineStrings are moved to SharedStrings.
Before
After
If the file is created and updated only using the Open XML SDK the InlineStrings are persisted and not moved to the SharedStringsTable.
I believe the InlineStrings feature is only relevant when working with files generated by the SDK. It is more convenient to lookup the value rather than mapping to the SharedStringTable using the SharedStringItem index.
Lookup value from the SharedStringTable:
https://stackoverflow.com/a/31739945/1165173
I don't know but is there any possible way to keep comments at a single place if it is repetitive, in visual studio editor?
Or something like to create link in comments and if we click on that link and it jumps to bunch of commented code, so we can just write the link where it is needed to write that bunch of code. So no repetitive comments are written.
The C# compiler allows you to reference an external XML file which contains the actual comments for a method. To do this you use an <include> element in the XML doc comment
/// <include file='file.doc' path='Parent/Child[#name="member"]/*' />
The contents of file.doc need to be an XML file and the comment for that method be at the XML path described in the path element
<Parent>
<Child name="member">
<summary>The actual comment</summary>
</Child>
</Parent>
More information is available here
I do not know if Visual Studio will allow you to click and follow through to the documentation. But the correct summary will be emitted in the file XML doc file for the assembly
I would like to ask one question relation to crm 2011 online email template.
In email template, I show Modified On Date. But It shows date and time. I want to show only date. How can achieve this? Please let me know any idea. Thanks....
There is no supported method to do this, however if you really need it, it might be worth trying this (note: I haven't tried this!).
Add your template to a solution (or a test one, for now), export it as unmanaged and edit the customizations.xml file. In the XML you will see a representation of your template with the dates in there. Look for the body node of your template and you'll see something like this in there (xml, encoded within xml):
<body><?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent="no"/>
<xsl:template match="/data">
<![CDATA[<font size=2 face="Tahoma, Verdana, Arial">
<p>Value of Created On: ]]>
<xsl:choose><xsl:when test="systemuser/createdon">
<xsl:value-of select="systemuser/createdon" />
</xsl:when><xsl:otherwise>
</xsl:otherwise></xsl:choose>
<![CDATA[</p>
<p>Value of Modified On: ]]>
<xsl:choose><xsl:when test="systemuser/modifiedon">
<xsl:value-of select="systemuser/modifiedon" />
</xsl:when><xsl:otherwise>
</xsl:otherwise></xsl:choose>
<![CDATA[</p><p> </p></font>]]>
</xsl:template></xsl:stylesheet></body>
Try changing any reference like this (note I'm using decoded values here):
<xsl:value-of select="systemuser/createdon" />
To this
<xsl:value-of select="ms:format-date('systemuser/createdon', 'dd MMM yyyy')"/>
Once you're done, save your customisations xml back into your solution zip and upload it. Even if it works when merging, it probably won't work if you try and edit it via the CRM UI.
This comes as an idea from reading this
You need to do the following:
Download the solution
Extract the zipped filed
search for your field by the logical name. So the Modified On field would be modifiedon.
on every match, add /#date after the match. Before: modifiedon. After: modifiedon/#date
Save the file, re-zip the solution folder, import it into the system and publish all customizations.
I know I have seen this somewhere before, but I cannot find it again. I need an example of calling an xsd file from within another xsd. This is quite useful where a number for xml files are being generated, but where there is large common areas between these xml files being validated. In that scenario, it is useful to have an xsd that validates the parts common to all xml files, then have separate smaller xsd validation files for the parts of the xml that are specific to each xml file.
Thanks
I'd probably call it referencing another XSD file (calling implies that the XSD is run or executed in some way, which isn't the case).
In any case you are probably looking for either the import or the include elements, for example:
<?xml version="1.0"?>
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/05/XMLInfoset" xmlns="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.example.com/IPO" />
<xs:include schemaLocation="example.xsd" />
</xs:schema>
What is the difference between import and include? Use import to reference declarations in a different namespace and include to reference declarations in the same namespace.
I'm trying to wrap my head around xml schemas and one thing I'm trying to figure out is how to do relational type schemas where on element refers to another, possibly in another schema altogether. I've looked at the xsd:key and xsd:keyref and it seems like the sort of thing I'm interested in, but I'm not sure. Initially I just set attributes with the type xs:ID abd xs:IDREF, which obviously doesn't necessarily refer to a specific element as far as I could tell.
Basically, I have several different xml files where elements refer to other elements either in the same file or other files. It looks a lot like a relation database and I would love to use one, but the requirement is to only use XML files and so I'm at least trying to establish some sanity instead of just seemingly random strings relying on xml comments to define the relationships. It works for smaller projects, but it's certainly not scalable.
Any thoughts?
I'm not aware of anything within XML Schema that will allow you to validate multiple XML documents against one another. In the xs:id and xs:key (etc) constraints, you use xpath to apply the constraints. You can go to XML Schema Part 1: Structures and scroll down a little bit for the example to see these constraints in action.
If you have the ability to define a meta-XML file that includes your others (perhaps by entity references if by no other way) and then use a schema for that meta file, then you should be able to use XML Schema to apply your constraints. If you define a schema for each of your XML file types, you should be able to trivially (by xs:import or xs:include) define a meta-schema for an XML file that includes all of your XML content in one XML file. This meta-schema could successfully apply the constraints you want.
Let's say you have to validate a Wiki that has many posts, where each post has an author and maybe many comments where each comment also has an author, and that you have one XML file for all posts, one for all comments, one for all authors, and you want to validate constraints between these files, that each post uses authors and comments that exist, that each comment uses authors that exist, and so on. Let's say you have the following three files:
The file /home/username/posts.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<posts>
<post>
<author name="author1"/>
<comment id="12345" pos="1"/>
<comment id="12346" pos="2"/>
<body>I really like my camera...</body>
</post>
...
</posts>
The file /home/username/comments.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<comments>
<comment id="12345" author="kindguy">
That was a very good post
</comment>
...
</comments>
The file /home/username/authors.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<authors>
<author name="kindguy" id="1"/>
<author name="author1" id="2"/>
...
</authors>
What I am suggesting is that you make a meta-XML file by using Entity References. For example, you could create the following XML file:
<?xml version="1.0" encoding="UTF-8" ?>
<!ENTITY postfile SYSTEM "file:///home/username/posts.xml">
<!ENTITY commentfile SYSTEM "file:///home/username/comments.xml">
<!ENTITY authorfile SYSTEM "file:///home/username/authors.xml">
<root>
&postfile1;
&commentfile;
&authorfile;
</root>
This meta-XML file (actually, a plain old XML file ... the "meta" is only from the perspective of your three defined XML files, and not in any XML sense) is the exact equivalent of the following file, and XML parsers will act as if you truly had the following file:
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<posts>
<post>
<author name="author1"/>
<comment id="12345" pos="1"/>
<comment id="12346" pos="2"/>
<body>I really like my camera...</body>
</post>
...
</posts>
<comments>
<comment id="12345" author="kindguy">
That was a very good post
</comment>
...
</comments>
<authors>
<author name="kindguy" id="1"/>
<author name="author1" id="2"/>
...
</authors>
</root>
From this file, you can define an XML schema that will apply the desired constraints, even though with the individual files there is no way to apply constraints. Since using XML entity notation you have "included" all the XML into one file, you can use xpath in the contraint references.
This issue is discussed in http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html note section 3.11.
If I remember correctly, xs:ID has to be globally unique within whole document, while xs:key only has to be unique for the element for which it was defined. So the key/keyref is actually more like PK/FK. PK only have to be unique within one table.