You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Roger Reed <Ro...@yahoo.com> on 2011/08/11 03:12:23 UTC

Problem with simple XML import operation

Hello,

I¹m trying to do what I think should be pretty simple, but I¹m obviously not
getting something.  I¹m just trying to import a simple XML file via curl and
view the result of the imported structure as JSON.   Steps I followed are
below.  I appreciate any input.

If I do a similar test using a JSON file as the import source I have no
issues.  The structure is imported.

I¹ve had zero luck with XML imports using a variety of test files.

Thanks,

Roger


java -jar org.apache.sling.launchpad-6-standalone.jar

curl -F:operation=import -F:contentType=xml -F:contentFile=@test.xml
http://admin:admin@localhost:8080/content/test

http://localhost:8080/content/test.json
http://localhost:8080/content/test.tidy.infinity.json

Both return:
{"jcr:primaryType": "nt:unstructured"}

I expected to see the XML structure as JSON, as I thought Sling would import
the XML as nodes.  What am I missing?


Contents of test.xml file:

<?xml version="1.0"?>
<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications
      with XML.</description>
   </book>
   <book id="bk112">
      <author>Galos, Mike</author>
      <title>Visual Studio 7: A Comprehensive Guide</title>
      <genre>Computer</genre>
      <price>49.95</price>
      <publish_date>2001-04-16</publish_date>
      <description>Microsoft Visual Studio 7 is explored in depth,
      looking at how Visual Basic, Visual C++, C#, and ASP+ are
      integrated into a comprehensive development
      environment.</description>
   </book>
</catalog>


Re: Problem with simple XML import operation

Posted by Roger Reed <Ro...@yahoo.com>.
Much thanks Eric.  I successfully imported a simple test XML file based on
the on the format at the URL you provided:

<?xml version="1.0"?>
<node>
        <name>xyz</name>
        <primaryNodeType>nt:unstructured</primaryNodeType>
    
        <mixinNodeType>mix:versionable</mixinNodeType>
        <mixinNodeType>mix:lockable</mixinNodeType>

        <property>
            <name>prop</name>
            <value>property value as string</value>
            <type>String</type>
        </property>
</node>


On 8/10/11 10:16 PM, "Eric Norman" <er...@gmail.com> wrote:

> Hi Roger,
> 
> The xml format that the import operation supports is the same as the xml
> format used by the content loader bundle that is documented at [1].  To
> import some other xml format you would need to create an xslt stylesheet to
> transform the xml into one of the supported formats.
> 
> 1. 
> http://sling.apache.org/site/content-loading-jcrcontentloader.htm<http://sling
> .apache.org/site/content-loading-jcrcontentloader.html>
> 
> Regards,
> Ericl <http://sling.apache.org/site/content-loading-jcrcontentloader.html>
> 
> On Wed, Aug 10, 2011 at 6:12 PM, Roger Reed <Ro...@yahoo.com> wrote:
> 
>> Hello,
>> 
>> I¹m trying to do what I think should be pretty simple, but I¹m obviously
>> not
>> getting something.  I¹m just trying to import a simple XML file via curl
>> and
>> view the result of the imported structure as JSON.   Steps I followed are
>> below.  I appreciate any input.
>> 
>> If I do a similar test using a JSON file as the import source I have no
>> issues.  The structure is imported.
>> 
>> I¹ve had zero luck with XML imports using a variety of test files.
>> 
>> Thanks,
>> 
>> Roger
>> 
>> 
>> java -jar org.apache.sling.launchpad-6-standalone.jar
>> 
>> curl -F:operation=import -F:contentType=xml -F:contentFile=@test.xml
>> http://admin:admin@localhost:8080/content/test
>> 
>> http://localhost:8080/content/test.json
>> http://localhost:8080/content/test.tidy.infinity.json
>> 
>> Both return:
>> {"jcr:primaryType": "nt:unstructured"}
>> 
>> I expected to see the XML structure as JSON, as I thought Sling would
>> import
>> the XML as nodes.  What am I missing?
>> 
>> 
>> Contents of test.xml file:
>> 
>> <?xml version="1.0"?>
>> <catalog>
>>   <book id="bk101">
>>      <author>Gambardella, Matthew</author>
>>      <title>XML Developer's Guide</title>
>>      <genre>Computer</genre>
>>      <price>44.95</price>
>>      <publish_date>2000-10-01</publish_date>
>>      <description>An in-depth look at creating applications
>>      with XML.</description>
>>   </book>
>>   <book id="bk112">
>>      <author>Galos, Mike</author>
>>      <title>Visual Studio 7: A Comprehensive Guide</title>
>>      <genre>Computer</genre>
>>      <price>49.95</price>
>>      <publish_date>2001-04-16</publish_date>
>>      <description>Microsoft Visual Studio 7 is explored in depth,
>>      looking at how Visual Basic, Visual C++, C#, and ASP+ are
>>      integrated into a comprehensive development
>>      environment.</description>
>>   </book>
>> </catalog>
>> 
>> 



Re: Problem with simple XML import operation

Posted by Eric Norman <er...@gmail.com>.
Hi Roger,

The xml format that the import operation supports is the same as the xml
format used by the content loader bundle that is documented at [1].  To
import some other xml format you would need to create an xslt stylesheet to
transform the xml into one of the supported formats.

1. http://sling.apache.org/site/content-loading-jcrcontentloader.htm<http://sling.apache.org/site/content-loading-jcrcontentloader.html>

Regards,
Ericl <http://sling.apache.org/site/content-loading-jcrcontentloader.html>

On Wed, Aug 10, 2011 at 6:12 PM, Roger Reed <Ro...@yahoo.com> wrote:

> Hello,
>
> I¹m trying to do what I think should be pretty simple, but I¹m obviously
> not
> getting something.  I¹m just trying to import a simple XML file via curl
> and
> view the result of the imported structure as JSON.   Steps I followed are
> below.  I appreciate any input.
>
> If I do a similar test using a JSON file as the import source I have no
> issues.  The structure is imported.
>
> I¹ve had zero luck with XML imports using a variety of test files.
>
> Thanks,
>
> Roger
>
>
> java -jar org.apache.sling.launchpad-6-standalone.jar
>
> curl -F:operation=import -F:contentType=xml -F:contentFile=@test.xml
> http://admin:admin@localhost:8080/content/test
>
> http://localhost:8080/content/test.json
> http://localhost:8080/content/test.tidy.infinity.json
>
> Both return:
> {"jcr:primaryType": "nt:unstructured"}
>
> I expected to see the XML structure as JSON, as I thought Sling would
> import
> the XML as nodes.  What am I missing?
>
>
> Contents of test.xml file:
>
> <?xml version="1.0"?>
> <catalog>
>   <book id="bk101">
>      <author>Gambardella, Matthew</author>
>      <title>XML Developer's Guide</title>
>      <genre>Computer</genre>
>      <price>44.95</price>
>      <publish_date>2000-10-01</publish_date>
>      <description>An in-depth look at creating applications
>      with XML.</description>
>   </book>
>   <book id="bk112">
>      <author>Galos, Mike</author>
>      <title>Visual Studio 7: A Comprehensive Guide</title>
>      <genre>Computer</genre>
>      <price>49.95</price>
>      <publish_date>2001-04-16</publish_date>
>      <description>Microsoft Visual Studio 7 is explored in depth,
>      looking at how Visual Basic, Visual C++, C#, and ASP+ are
>      integrated into a comprehensive development
>      environment.</description>
>   </book>
> </catalog>
>
>