NEWBIE HERE- HELLPP!

Questions about XML that are not covered by the other forums should go here.
502hollywood
Posts: 5
Joined: Wed Aug 25, 2021 7:38 am

NEWBIE HERE- HELLPP!

Post by 502hollywood »

Howdy!

Using the grid view, once I get the first record formatted correctly, how do I copy this to all of the remaining records?

I imported an excel file and decided to use the grid view to format? I do have a schema file, but not sure how to use the schema file (xml map I made in notepad) to format the excel file in oxygen.

Thanks for the help!
Cheers
CXS
Radu
Posts: 8283
Joined: Fri Jul 09, 2004 5:18 pm

Re: NEWBIE HERE- HELLPP!

Post by Radu »

Hi,

I'm afraid the Grid editing mode does not have such capabilities.
Maybe you can give us a small example with how the imported XML looks like and what changes you made to it.
Oxygen has support for XML refactoring actions so maybe a custom XML refactoring action based on XSLT could modify the imported XML in the way that you want.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
502hollywood
Posts: 5
Joined: Wed Aug 25, 2021 7:38 am

Re: NEWBIE HERE- HELLPP!

Post by 502hollywood »

Thank you for the help!

So the excel file imports like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<root Attribute="">
    <row>
        <createddate>2021-06-16T12:48:23</createddate>
        <externalstudentid1>xxxxxxxx</externalstudentid1>
        <externalfundid>xxxxxxxxxx</externalfundid>
        <awardstatus>Accepted</awardstatus>
        <awardamount>500</awardamount>
        <awardstartdate>2021-08-30T00:00:00</awardstartdate>
        <awardenddate>2021-11-20T00:00:00</awardenddate>
        <awardyear>2022</awardyear>
        <offeredondate>2021-08-24T00:00:00</offeredondate>
And I need it to look like this:

Code: Select all

<persons createdDate="2021-06-16T12:48:23">
<person externalStudentId1="xxxxxxxxxxxx">
    <award awardAmount="1548" awardEndDate="2021-05-12" awardStartDate="2021-02-18" awardStatus="Accepted" externalAwardId="xxxxxxxxx" externalFundId="xxxxxxxx" AwardYear="2021" manualAward="true" maxDisbursementNumber="1" offeredOnDate="2021-02-05" >
      </award>
     </person>
</persons>
The refactoring option sounds great! How would I build one and apply it?

Cheers-
CXS
Radu
Posts: 8283
Joined: Fri Jul 09, 2004 5:18 pm

Re: NEWBIE HERE- HELLPP!

Post by Radu »

Hi,

Refactoring actions are for usually making small changes in an XML document, you seem to actually want to convert an XML document to another type of XML document. This is done with XSLT stylesheets.
If you create for example a file named "convert.xsl" with the content I'm attaching below:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  exclude-result-prefixes="xs"
  version="2.0">
  <xsl:output indent="yes"/>
  <xsl:template match="root">
    <persons>
      <xsl:apply-templates/>
    </persons>
  </xsl:template>
  <xsl:template match="row">
    <person>
      <xsl:attribute name="createdDate" select="createddate/text()"/>
      <award>
        <xsl:attribute name="awardAmount" select="awardamount/text()"/>
        <xsl:attribute name="awardEndDate" select="awardenddate/text()"/>
        <xsl:attribute name="awardStartDate" select="awardstartdate/text()"/>
        <xsl:attribute name="externalFundId" select="externalfundid/text()"/>
        <!-- AND SO ON -->
      </award>
    </person>
  </xsl:template>
</xsl:stylesheet>
you can create in Oxygen a new transformation scenario and apply the XSLT over the XML document:

https://www.oxygenxml.com/doc/versions/ ... -xslt.html

but the XSLT needs to be further modified according to your needs.
More about how you can learn XSLT: https://blog.oxygenxml.com/xslt_training.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
502hollywood
Posts: 5
Joined: Wed Aug 25, 2021 7:38 am

Re: NEWBIE HERE- HELLPP!

Post by 502hollywood »

Many blessings to you!

Your solution got me started on the right path.

Thanks, again!
CXS
502hollywood
Posts: 5
Joined: Wed Aug 25, 2021 7:38 am

Re: NEWBIE HERE- HELLPP!

Post by 502hollywood »

Would you happen to know how I can change the settings for when I import an excel sheet that has the date format YYYY-MM-DD, oxygen coverts it to YYYY-MM-DDT00:00:00?
Radu
Posts: 8283
Joined: Fri Jul 09, 2004 5:18 pm

Re: NEWBIE HERE- HELLPP!

Post by Radu »

Hi,

I'm afraid we do not have extra settings, besides the ones in the import dialog.
If you are using a conversion XSLT you can modify the date pattern when you convert to the other XML format:

Code: Select all

<xsl:attribute name="createdDate" select="replace(createddate/text(), 'T00:00:00', '')"/>
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply