Web Connection Wishlist
wwConfig - XML
Gravatar is a globally recognized avatar based on your email address. wwConfig - XML
  FoxInCloud Support - Thierry N.
  All
  Nov 24, 2017 @ 02:09am

Hi,

Using wwConfig.cMode = 'XML', just had an issue with JustStem(THIS.cFileName) beginning with a digit: XML parser rejects a node name beginning with a digit.

text to cXML noshow && (simplified XML)
<?xml version="1.0"?>
<4manufacturing.pjx-awadapter>
	<config type="object" class="awadapterpjconfig">
		<adaptuser>paul</adaptuser>
		<adaptusertest></adaptusertest>
		<refreshtest></refreshtest>
		<share></share>
	</config>
</4manufacturing.pjx-awadapter>
endtext

o = CreateObject('msxml.domdocument')
? o.loadXML(m.cXML) && .F.
? o.parseError.reason && name begins with an invelid character
? o.parseError.line && 2 ('<4manufacturing.pjx-awadapter>')

Here is a suggested workaround (have not seen any dependency on the root node name elsewhere):

PROTECTED FUNCTION CreateXML
…
loXML.cDocRootName = lower(JustStem(THIS.cFileName)) && XML parser rejects a digit as 1rst character of a node name
loXML.cDocRootName = iif(isDigit(loXML.cDocRootName), '_', '')  + loXML.cDocRootName && suggestion to add this line
…
Gravatar is a globally recognized avatar based on your email address. re: wwConfig - XML
  Rick Strahl
  FoxInCloud Support - Thierry N.
  Nov 26, 2017 @ 12:02pm

A number in a document node is invalid by the XML spec which is why it gets rejected by the parser. It's also illegal for FoxPro variables so this would cause a problem in conversion as well if it is related to an actual child element that maps to a property (which it is not in this case) .


XML Naming Rules

XML elements must follow these naming rules:

  • Element names are case-sensitive
  • Element names must start with a letter or underscore
  • Element names cannot start with the letters xml (or XML, or Xml, etc)
  • Element names can contain letters, digits, hyphens, underscores, and periods
  • Element names cannot contain spaces

Any name can be used, no words are reserved (except xml).


Your fix works for that specific use case but not if there's any other node that has invalid values. YOu shouldn't be able to create XML like that if you use a valid parser to create the XML.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwConfig - XML
  FoxInCloud Support - Thierry N.
  Rick Strahl
  Nov 26, 2017 @ 11:11pm

of course, I'm just addressing the bug of this line:

PROTECTED FUNCTION CreateXML
…
loXML.cDocRootName = lower(JustStem(THIS.cFileName)) && XML parser rejects a digit as 1rst character of a node name

As the file naming and the XML node naming rules differ, you end up with a bug if the file name does not match a node naming rules.

By the way, as the root node's only functionality is to give the document a root node, you could just have (like cursorToXML() does):

PROTECTED FUNCTION CreateXML
…
loXML.cDocRootName = 'VFPData'

How do you plan to fix this bug?

Gravatar is a globally recognized avatar based on your email address. re: wwConfig - XML
  Rick Strahl
  FoxInCloud Support - Thierry N.
  Nov 27, 2017 @ 03:43pm

That'll teach me to not read the whole message 😃

I think this is what we need here based on XML rules:

loXML.cDocRootName = lower(JustStem(THIS.cFileName)) && XML parser rejects a digit as 1rst character of a node name
loXML.cDocRootName = iif( !ISALPHA(loXml.cDocRootName) AND !StartsWith("_"), '_', '')  + loXML.cDocRootName && suggestion to add this line

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwConfig - XML
  FoxInCloud Support - Thierry N.
  Rick Strahl
  Nov 28, 2017 @ 01:08am

humm, looks like a JavaScript or C# bias somewhere… 😉

loXML.cDocRootName = iif( !ISALPHA(loXml.cDocRootName) AND !StartsWith(loXML.cDocRootName, "_"), '_', '')  + loXML.cDocRootName

otherwise perfect, thanks

© 1996-2024