PDA

View Full Version : Cross-Eyed XML


Worm
09-01-2005, 08:18 AM
I've been throught this XML file way too many times now and cannot find the error in it. Everything seems okay, but AMS (5 & 6) give me errors when loading it for the actions.

If anyone has a moment to take a look, I'd appreciate the extra eyes

<ActionTemplates>
<Action>
<Name>DateDiff.AddDays</Name>
<Description>Adds the specified number of days to the date.</Description>
<ReturnValueType>string</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>The date to be added to.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Days</Name>
<Description>The number of days to add.</Description>
<Type>number</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>10</Default>
<DataType>number</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.AddMonths</Name>
<Description>Adds the specified number of months to the date.</Description>
<ReturnValueType>string</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>The date to be added to.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Months</Name>
<Description>The number of months to add.</Description>
<Type>number</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>10</Default>
<DataType>number</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.AddYears</Name>
<Description>Adds the specified number of years to the date.</Description>
<ReturnValueType>string</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>The date to be added to.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Years</Name>
<Description>The number of years to add.</Description>
<Type>number</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>10</Default>
<DataType>number</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.FormatSeconds</Name>
<Description>formats seconds into a string HH:MM:SS.</Description>
<ReturnValueType>number</ReturnValueType>
<Arguments>
<Arg>
<Name>Seconds</Name>
<Description>The number of seconds to format.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>3661</Default>
<DataType>number</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.GetDayOfWeek</Name>
<Description>returns a numeric representation of the day of the week.</Description>
<ReturnValueType>number</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>The date to return the day of the week for.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.IsEqual</Name>
<Description>Compares Date1 with Date2</Description>
<ReturnValueType>boolean</ReturnValueType>
<Arguments>
<Arg>
<Name>Date1</Name>
<Description>first date in the expression.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Date2</Name>
<Description>second date in the expression.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/25/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.IsGreaterThan</Name>
<Description>Compares Date1 with Date2.</Description>
<ReturnValueType>boolean</ReturnValueType>
<Arguments>
<Arg>
<Name>Date1</Name>
<Description>first date in the expression.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Date2</Name>
<Description>second date in the expression.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/25/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.IsLessThan</Name>
<Description>Compares Date1 with Date2.</Description>
<ReturnValueType>boolean</ReturnValueType>
<Arguments>
<Arg>
<Name>Date1</Name>
<Description>first date in the expression.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Date2</Name>
<Description>second date in the expression.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/25/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.IsValid</Name>
<Description>check to see if the date is valid</Description>
<ReturnValueType>boolean</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>the date to check for validity.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.SubtractDays</Name>
<Description>Subtract the specified number of days from the date.</Description>
<ReturnValueType>string</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>The date to be subracted from.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Days</Name>
<Description>The number of days to subtract.</Description>
<Type>number</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>10</Default>
<DataType>number</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.SubtractMonths</Name>
<Description>Subtracts the specified number of months from the date.</Description>
<ReturnValueType>string</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>The date to be subtracted from.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Months</Name>
<Description>The number of months to subtract.</Description>
<Type>number</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>10</Default>
<DataType>number</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
<Action>
<Name>DateDiff.SubtractYears</Name>
<Description>Subtracts the specified number of years from the date.</Description>
<ReturnValueType>string</ReturnValueType>
<Arguments>
<Arg>
<Name>Date</Name>
<Description>The date to be subtracted from.</Description>
<Type>string</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>"01/01/2005"</Default>
<DataType>string</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
<Arg>
<Name>Years</Name>
<Description>The number of years to subtract.</Description>
<Type>number</Type>
<Default/>
<Required>1</Required>
<EasyMode>
<Default>10</Default>
<DataType>number</DataType>
<Constraints>none</Constraints>
</EasyMode>
</Arg>
</Arguments>
</Action>
</ActionTemplates>

bnkrazy
09-01-2005, 08:23 AM
Ran it through the validator: http://www.w3schools.com/dom/dom_validate.asp

and it said it was fine...

I introduced a malformed tag and it caught it...so I assume the validator is working correctly...

btw...the validator only works in IE

Worm
09-01-2005, 08:33 AM
I tried that too with the same results, but once the file is compiled into my plugin, AMS doesn't like it. Also the error message indicates it's not getting the name of my plugin properly. But, like I said, if I take the last 2 actions out of my XML, everything loads and works fine.

All the actions still work, but the XML is hosed somewhere... :eek:

Worm
09-01-2005, 08:48 AM
Okay, I don't think it's the XML.

I droped the XML file into the Data\Actions folder and AMS reads it from there without any errors. So... the question is why does it error when reading it as a resource?

Brett
09-01-2005, 09:17 AM
Worm,

I have run into this before. I bet it is the irPlg_GetPluginActionXML function in the DLL. For example, the Clipboard plugin's function looks like this:

#define SIZE_XML_STRING 10000

char szXML[SIZE_XML_STRING];

// stuff...

int irPlg_GetPluginActionXML(char* szBuffer, int* pnBufferSize)
{
memset(szXML,0,10000);
if(!IR_PLUGIN_GetTextFromResourceFile("TEXTFILE",IDR_ACTIONSXML,szXML,SIZE_XML_STRING))
{
lstrcpy(szXML,"");
}

int nLength = lstrlen(szXML);
if(*pnBufferSize < nLength)
{
*pnBufferSize = nLength;
return -1;
} else
{
memset(szBuffer,0,*pnBufferSize);
lstrcpy(szBuffer,szXML);
return nLength;
}
}

My guess is that your XML is larger than the string is allocated for. Try changing this:

#define SIZE_XML_STRING 10000

to:

#define SIZE_XML_STRING 100000

(or whatever size you want)

And then change:

memset(szXML,0,10000);

to be:

memset(szXML,0,SIZE_XML_STRING);

I am not sure of your code, but that is probably the problem.

Worm
09-01-2005, 09:26 AM
That did it. Thanks Brett :lol

You don't even want to know how much time I spent pouring over that XML file. Sheesh!

Brett
09-01-2005, 09:41 AM
Been there. Done that. Bought the shirt.

Worm
09-01-2005, 09:55 AM
Is it a one size fits all? If so, can I borrow it :)