How create XML-documents?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How create XML-documents?

cJJUNnH41s90Y
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How create XML-documents?

Kyle Jessup

On Jun 7, 2005, at 7:33 AM, noah williamsson wrote:

> I'd like to create an XML-document like the one below.
> How can i do this in Lasso?
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root attr="test">
> <foo>bar</foo>
> <quux attr="test2" />
> </root>
>
> I've tried:
> var: 'xml' = (xml);
> var: 'xml_node' = $xml->document;
> var: 'xml_root' = $xml_node->newchild;
>
> ..but that fails with "An invalid parameter was passed to a tag" at  
> $xml_node->newchild.
>
>
> By the way, not all XML-tags show up when you search for XML on  
> ldml.omnipilot.com. For example, i found xml->setname in related  
> tags for some tag but can't find it when i search for 'xml'.
>
> Also, the syntax example for xml->documents is broken on 8.0.4,  
> initalizing a variable with a zero-length string gives an error.
>
>
> Thanks in advance,
>   -- noah

->newChild requires one parameter, the name of the new node. The LDML  
ref is incorrect on this (my bad), so I've entered a bug on it.

local: 'xml' = xml;
local: 'xml_node' = $xml->document;
local: 'xml_root' = $xml_node->newchild:'node';

$xml;

Thanks,
-K

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: How create XML-documents?

cJJUNnH41s90Y
In reply to this post by cJJUNnH41s90Y
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How create XML-documents?

Kyle Jessup
In reply to this post by cJJUNnH41s90Y
On Jun 7, 2005, at 10:11 AM, noah williamsson wrote:

> [hidden email] wrote:
>
>> On Jun 7, 2005, at 7:33 AM, noah williamsson wrote:
>>
>>>  I'd like to create an XML-document like the one below.
>>>  How can i do this in Lasso?
>>>
>>>  <?xml version="1.0" encoding="UTF-8"?>
>>>  <root attr="test">
>>>  <foo>bar</foo>
>>>  <quux attr="test2" />
>>>  </root>
>>>
>>>
>> ->newChild requires one parameter, the name of the new node. The  
>> LDML  ref is incorrect on this (my bad), so I've entered a bug on it.
>>
>
> Thanks!
>
> Is it possible to set attributes on elements with Lasso?
> I can't find anything related to setting attributes on LDML, only  
> removing them or getting their associated values.

Yes, there is an ->addAttribute tag. It is missing from the LDML ref  
(not my bad!)
Example:
     #xml->addAttribute:'name'='value';

Here are my original notes on the XML additions which were added for  
LP8 (with ->newChild corrected):

->setName(string) - Sets the name of the XML node
->addAttribute(pair) - Adds the new attribute to the XMl node.
->removeAttribute(string) - Removes the named attribute from the XML  
node
->firstChild - Returns the first child node
->lastChild - Returns the last child node
->addChild(xml) - Adds the given XML node as a child of the target  
node. A copy of the given node is made.
->addSibling(xml) - Adds the given XML node as a sibling of the  
target node. A copy of the given node is made.
->addNextSibling(xml) - Adds the given XML node as the next sibling  
of the target node. A copy of the given node is made.
->addPrevSibling(xml) - Adds the given XML node as the previous  
sibling of the target node. A copy of the given node is made.
->addContent(string) - Adds the given text to the content of the  
target node.
->replaceWith(xml) - Replaces the target node with the given node.
->findNamespace(string) - Finds a namespace by name
     local('x' = xml('<xml xmlns:x="urn111">12</xml>'));
     #x->findNamespace('x');
     = pair: (x)=(urn111)
->findNamespaceByhref(string) - Finds a namespace by its href
     local('x' = xml('<xml xmlns:x="urn111">12</xml>'));
     #x->findNamespaceByhref('urn111');
     = pair: (x)=(urn111)
->newChild(string) - Adds a new XML node with the given name as a  
child of the target node and returns it.
->removeChild(xml) - Removes the given node from the target node's  
document.
->getAttribute(string) - Searches for the attribute by name, and if  
found, returns it.
->addNamespace(pair) - Adds a new namespace to the target node.
     local('x' = xml('<xml>12</xml>'));
     #x->addNamespace('x'='urn111');
     = <xml xmlns:x="urn111">12</xml>
->removeNamespace(string) - Removes the namespace from the target node.
     local('x' = xml('<xml xmlns:x="urn111">12</xml>'));
     #x->removeNamespace('x');
     = <xml>12</xml>


-K

--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage