Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
XML
data.xmlanalysis
mappoint.webservice
msf
msxml-webrelease
netmyservices.sdk
passport.sdk
soap
soapsdk
uddi.general
uddi.programming
uddi.specification
xml
xmlsqlwebrelease
xsl
  
 
date: Mon, 25 Feb 2008 16:40:10 -0800,    group: microsoft.public.xsl        back       


How do get the root node?   
I have been displaying a new root node <dataset> with my transformations.

How do I get the file to use the old root node in my transformation?

How would I change the following xslt file to accomplish that?

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template match="/">
   <dataset>
    <xsl:apply-templates>
     <xsl:sort select="form/@primary" order="descending"/>
    </xsl:apply-templates>
   </dataset>
 </xsl:template>
 <xsl:template match="tag">
  <form>
   <sectionNumber>
    <xsl:value-of select="ancestor::section/@number"/>
   </sectionNumber>
   <primary>
    <xsl:value-of select="ancestor::form/@primary"/>
   </primary>
   <formName>
    <xsl:value-of select="ancestor::form/@name"/>
   </formName>
   <tagName>
    <xsl:value-of select="@name"/>
   </tagName>
   <flags>
    <xsl:if test="not(@flags)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@flags"/>
   </flags>
   <format>
    <xsl:if test="not(@format)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@format"/>
   </format>
   <value>
    <xsl:value-of select="."/>
   </value>
  </form>
 </xsl:template>
  <xsl:template match="attachments/attachment">
    <attachment>
      <key>
        <xsl:value-of select="@key"/>
      </key>
      <type>
        <xsl:value-of select="@type"/>
      </type>
      <label>
        <xsl:value-of select="@label"/>
      </label>
      <format>
        <xsl:value-of select="image/binary/@format"/>
      </format>
      <image>
        <xsl:value-of select="image/binary/text()"/>
      </image>
      <thumbnailFormat>
        <xsl:value-of select="thumbnail/binary/@format"/>
      </thumbnailFormat>
      <thumbnailImage>
        <xsl:value-of select="thumbnail/binary/text()"/>
      </thumbnailImage>
    </attachment>
  </xsl:template>
</xsl:stylesheet>

I want the file to work as it does not but replace the <dataset></dataset> 
tags with whatever the root nodes were.

Thanks,

Tom
date: Mon, 25 Feb 2008 16:40:10 -0800   author:   tshad

Re: How do get the root node?   
U¿ytkownik "tshad"  napisa³ w wiadomo¶ci 
news:eAIOxBBeIHA.748@TK2MSFTNGP04.phx.gbl...
>How do get the root node?

/*

What exactly do you want to do?
-- 
td
date: Tue, 26 Feb 2008 09:09:15 +0100   author:   TOUDIdel

Re: How do get the root node?   
tshad wrote:

> I want the file to work as it does not but replace the <dataset></dataset> 
> tags with whatever the root nodes were.


Can you show us an example of your XML input? If you want to copy the 
root element you can do that with
   <xsl:template match="/*">
     <xsl:copy>
       <xsl:apply-templates/>
     </xsl:copy>
   </xsl:template>
but without seeing the XML input it is difficult to suggest what else 
needs to be adapted in the stylesheet.

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Tue, 26 Feb 2008 12:58:57 +0100   author:   Martin Honnen

Re: How do get the root node?   
"Martin Honnen"  wrote in message 
news:uvSk87GeIHA.5552@TK2MSFTNGP06.phx.gbl...
> tshad wrote:
>
>> I want the file to work as it does not but replace the 
>> <dataset></dataset> tags with whatever the root nodes were.
>
>
> Can you show us an example of your XML input? If you want to copy the root 
> element you can do that with
>   <xsl:template match="/*">
>     <xsl:copy>
>       <xsl:apply-templates/>
>     </xsl:copy>
>   </xsl:template>
> but without seeing the XML input it is difficult to suggest what else 
> needs to be adapted in the stylesheet.
>

Following is a snippet of the xml file.

At the moment we end up with 2 tables (form and attachments) with my dataset 
from this xsl sheet and the root node will end up with <data></data> as the 
root.

I want to change that to put whatever is in the root of the XML file 
(Argus-Report in this example) as the root of the transformation so I should 
see something like:

<?xml version="1.0" encoding="UTF-8"?>
<Argus-Report>
    <form>
   </form>
   <attachment>
   </attachment>
</Argus-Report>

At the moment I am getting:
<?xml version="1.0" encoding="UTF-8"?>
<dataset>
    <form>
   </form>
   <attachment>
   </attachment>
</dataset>

The XML file.

<?xml version="1.0" encoding="UTF-8"?>
<Argus-Report>
 <approval>
  <data>
   <form name="order" primary="false">
    <tag name="NAME.1" flags="1" format="4096">Marco</tag>
   </form>
   <form name="lot" primary="false">
    <tag name="NAME.2" flags="1" format="4096">John Doe</tag>
   </form>
   <form name="title" primary="false">
    <tag name="APPR_NAME.1" flags="1" format="12288">John Doe</tag>
   </form>
   <form name="13781" primary="true">
    <section type="subject" number="0">
     <tag name="CITY.1" flags="1" format="4096">Irvine</tag>
     <tag name="STATE.1" flags="1" format="4096">CA</tag>
     <tag name="COUNTY.1" flags="1" format="4096">Orange</tag>
    </section>
    <section type="sales" number="1">
     <tag name="GS_AGE.1" flags="1" format="4096">1</tag>
     <tag name="GS_SITE.1" flags="1" format="102">12000</tag>
     <tag name="GS_VIEW.1" flags="1" format="4096">ocean</tag>
    </section>
    <section type="sales" number="2">
     <tag name="GS_AGE.1" flags="1" format="4096">1</tag>
     <tag name="GS_SITE.1" flags="1" format="4096">15000</tag>
     <tag name="GS_VIEW.1" flags="1" format="4096">none</tag>
    </section>
   </form>
   <form name="subjectphotopage" primary="false">
    <section type="subject" number="0">
     <tag name="AS_OF_DATE.1" flags="1" format="4096">December 12, 
2007</tag>
     <tag name="DATE_SIGNED.1" flags="0" format="0">12/12/2007</tag>
     <tag name="ESTIMATED.1" flags="8" format="4128">1000000</tag>
    </section>
    <tag name="PHOTO_FILE.1" flags="4096" 
format="12288">ancestor::approval/attachments/attachment[1]</tag>
    <tag name="PHOTO_FILE.2" flags="4096" 
format="12288">ancestor::approval/attachments/attachment[2]</tag>
   </form>
  </data>
   <attachments>
    <attachment key="db8d208f-b049-4caa-bac0-eeb4cf9007d6" type="photo" 
label=" Sale #1">
    <image>
     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
dt:dt="bin.base64" format="jpeg">
    </image>
    <thumbnail>
     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
dt:dt="bin.base64" format="jpeg">
    </thumbnail>
   </attachment>
    <attachment key="db8d208f-b049-4caa-bac0-eeb4cf9007d6" type="photo" 
label=" Sale #1">
    <image>
     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
dt:dt="bin.base64" format="jpeg">
    </image>
    <thumbnail>
     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
dt:dt="bin.base64" format="jpeg">
    </thumbnail>
   </attachment>
  </attachments>
 </approval>
</Argus-Report>

The other thing I need to figure out is how to get the value from the 
attributes "xmlns:dt" and "dt:dt" in the binary tag.

Thanks,

Tom

> -- 
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
date: Wed, 27 Feb 2008 16:08:31 -0800   author:   tshad

Re: How do get the root node?   
I forgot to add the xlst file I am using:

Below:

"tshad"  wrote in message 
news:%232Imb5ZeIHA.4744@TK2MSFTNGP06.phx.gbl...
>
> "Martin Honnen"  wrote in message 
> news:uvSk87GeIHA.5552@TK2MSFTNGP06.phx.gbl...
>> tshad wrote:
>>
>>> I want the file to work as it does not but replace the 
>>> <dataset></dataset> tags with whatever the root nodes were.
>>
>>
>> Can you show us an example of your XML input? If you want to copy the 
>> root element you can do that with
>>   <xsl:template match="/*">
>>     <xsl:copy>
>>       <xsl:apply-templates/>
>>     </xsl:copy>
>>   </xsl:template>
>> but without seeing the XML input it is difficult to suggest what else 
>> needs to be adapted in the stylesheet.
>>
>
> Following is a snippet of the xml file.
>
> At the moment we end up with 2 tables (form and attachments) with my 
> dataset from this xsl sheet and the root node will end up with 
> <data></data> as the root.
>
> I want to change that to put whatever is in the root of the XML file 
> (Argus-Report in this example) as the root of the transformation so I 
> should see something like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Argus-Report>
>    <form>
>   </form>
>   <attachment>
>   </attachment>
> </Argus-Report>
>
> At the moment I am getting:
> <?xml version="1.0" encoding="UTF-8"?>
> <dataset>
>    <form>
>   </form>
>   <attachment>
>   </attachment>
> </dataset>
>
> The XML file.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Argus-Report>
> <approval>
>  <data>
>   <form name="order" primary="false">
>    <tag name="NAME.1" flags="1" format="4096">Marco</tag>
>   </form>
>   <form name="lot" primary="false">
>    <tag name="NAME.2" flags="1" format="4096">John Doe</tag>
>   </form>
>   <form name="title" primary="false">
>    <tag name="APPR_NAME.1" flags="1" format="12288">John Doe</tag>
>   </form>
>   <form name="13781" primary="true">
>    <section type="subject" number="0">
>     <tag name="CITY.1" flags="1" format="4096">Irvine</tag>
>     <tag name="STATE.1" flags="1" format="4096">CA</tag>
>     <tag name="COUNTY.1" flags="1" format="4096">Orange</tag>
>    </section>
>    <section type="sales" number="1">
>     <tag name="GS_AGE.1" flags="1" format="4096">1</tag>
>     <tag name="GS_SITE.1" flags="1" format="102">12000</tag>
>     <tag name="GS_VIEW.1" flags="1" format="4096">ocean</tag>
>    </section>
>    <section type="sales" number="2">
>     <tag name="GS_AGE.1" flags="1" format="4096">1</tag>
>     <tag name="GS_SITE.1" flags="1" format="4096">15000</tag>
>     <tag name="GS_VIEW.1" flags="1" format="4096">none</tag>
>    </section>
>   </form>
>   <form name="subjectphotopage" primary="false">
>    <section type="subject" number="0">
>     <tag name="AS_OF_DATE.1" flags="1" format="4096">December 12, 
> 2007</tag>
>     <tag name="DATE_SIGNED.1" flags="0" format="0">12/12/2007</tag>
>     <tag name="ESTIMATED.1" flags="8" format="4128">1000000</tag>
>    </section>
>    <tag name="PHOTO_FILE.1" flags="4096" 
> format="12288">ancestor::approval/attachments/attachment[1]</tag>
>    <tag name="PHOTO_FILE.2" flags="4096" 
> format="12288">ancestor::approval/attachments/attachment[2]</tag>
>   </form>
>  </data>
>   <attachments>
>    <attachment key="db8d208f-b049-4caa-bac0-eeb4cf9007d6" type="photo" 
> label=" Sale #1">
>    <image>
>     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
> dt:dt="bin.base64" format="jpeg">
>    </image>
>    <thumbnail>
>     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
> dt:dt="bin.base64" format="jpeg">
>    </thumbnail>
>   </attachment>
>    <attachment key="db8d208f-b049-4caa-bac0-eeb4cf9007d6" type="photo" 
> label=" Sale #1">
>    <image>
>     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
> dt:dt="bin.base64" format="jpeg">
>    </image>
>    <thumbnail>
>     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
> dt:dt="bin.base64" format="jpeg">
>    </thumbnail>
>   </attachment>
>  </attachments>
> </approval>
> </Argus-Report>
>

The XLST file:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template match="/">
  <root_node>
   <dataset>
    <xsl:apply-templates>
     <xsl:sort select="form/@primary" order="descending"/>
    </xsl:apply-templates>
   </dataset>
  </root_node>
 </xsl:template>
 <xsl:template match="tag">
  <form>
   <sectionNumber>
    <xsl:value-of select="ancestor::section/@number"/>
   </sectionNumber>
   <primary>
    <xsl:value-of select="ancestor::form/@primary"/>
   </primary>
   <formName>
    <xsl:value-of select="ancestor::form/@name"/>
   </formName>
   <tagName>
    <xsl:value-of select="@name"/>
   </tagName>
   <flags>
    <xsl:if test="not(@flags)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@flags"/>
   </flags>
   <format>
    <xsl:if test="not(@format)">
     <xsl:attribute name="xsi:nil">true</xsl:attribute>
    </xsl:if>
    <xsl:value-of select="@format"/>
   </format>
   <value>
    <xsl:value-of select="."/>
   </value>
  </form>
 </xsl:template>
  <xsl:template match="attachments/attachment">
    <attachment>
      <key>
        <xsl:value-of select="@key"/>
      </key>
      <type>
        <xsl:value-of select="@type"/>
      </type>
      <label>
        <xsl:value-of select="@label"/>
      </label>
      <format>
        <xsl:value-of select="image/binary/@format"/>
      </format>
      <image>
        <xsl:value-of select="image/binary/text()"/>
      </image>
      <thumbnailFormat>
        <xsl:value-of select="thumbnail/binary/@format"/>
      </thumbnailFormat>
      <thumbnailImage>
        <xsl:value-of select="thumbnail/binary/text()"/>
      </thumbnailImage>
    </attachment>
  </xsl:template>
</xsl:stylesheet>


> The other thing I need to figure out is how to get the value from the 
> attributes "xmlns:dt" and "dt:dt" in the binary tag.
>
> Thanks,
>
> Tom
>
>> -- 
>>
>> Martin Honnen --- MVP XML
>> http://JavaScript.FAQTs.com/
>
>
date: Mon, 3 Mar 2008 10:31:58 -0800   author:   tshad

Re: How do get the root node?   
tshad wrote:
> I forgot to add the xlst file I am using:

>  <xsl:template match="/">
>   <root_node>
>    <dataset>
>     <xsl:apply-templates>
>      <xsl:sort select="form/@primary" order="descending"/>
>     </xsl:apply-templates>
>    </dataset>
>   </root_node>
>  </xsl:template>

Change that template to

  <xsl:template match="/*">
   <xsl:copy>
     <xsl:apply-templates>
      <xsl:sort select="form/@primary" order="descending"/>
     </xsl:apply-templates>
   </xsl:copy>
  </xsl:template>




-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Tue, 04 Mar 2008 16:08:38 +0100   author:   Martin Honnen

Re: How do get the root node?   
"Martin Honnen"  wrote in message 
news:e526kmgfIHA.4196@TK2MSFTNGP04.phx.gbl...
> tshad wrote:
>> I forgot to add the xlst file I am using:
>
>>  <xsl:template match="/">
>>   <root_node>
>>    <dataset>
>>     <xsl:apply-templates>
>>      <xsl:sort select="form/@primary" order="descending"/>
>>     </xsl:apply-templates>
>>    </dataset>
>>   </root_node>
>>  </xsl:template>
>
> Change that template to
>
>  <xsl:template match="/*">
>   <xsl:copy>
>     <xsl:apply-templates>
>      <xsl:sort select="form/@primary" order="descending"/>
>     </xsl:apply-templates>
>   </xsl:copy>
>  </xsl:template>
>
That would work fine.

How do I also handle the "xmlns:dt" and the "dt:dt" to get the bin.base64 in 
the xslt file?

  <image>
     <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
dt:dt="bin.base64" format="jpeg">
    </image>

Thanks,

Tom
date: Sun, 9 Mar 2008 19:05:21 -0700   author:   tshad

Re: How do get the root node?   
tshad wrote:

> How do I also handle the "xmlns:dt" and the "dt:dt" to get the bin.base64 in 
> the xslt file?
> 
>   <image>
>      <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
> dt:dt="bin.base64" format="jpeg">
>     </image>

dt:dt is an attribute of the binary element so you can access it like this:
   <xsl:stylesheet
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0"
     xmlns:dt="urn:schemas-microsoft-com:datatypes">

     <xsl:template match="/">
       <xsl:value-of select="image/binary/@dt:dt"/>
     </xsl:template>
   </xsl:stylesheet>

-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/
date: Mon, 10 Mar 2008 13:04:53 +0100   author:   Martin Honnen

Re: How do get the root node?   
"Martin Honnen"  wrote in message 
news:ObQD3bqgIHA.748@TK2MSFTNGP04.phx.gbl...
> tshad wrote:
>
>> How do I also handle the "xmlns:dt" and the "dt:dt" to get the bin.base64 
>> in the xslt file?
>>
>>   <image>
>>      <binary xmlns:dt="urn:schemas-microsoft-com:datatypes" 
>> dt:dt="bin.base64" format="jpeg">
>>     </image>
>
> dt:dt is an attribute of the binary element so you can access it like 
> this:
>   <xsl:stylesheet
>     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>     version="1.0"
>     xmlns:dt="urn:schemas-microsoft-com:datatypes">
>
>     <xsl:template match="/">
>       <xsl:value-of select="image/binary/@dt:dt"/>
>     </xsl:template>
>   </xsl:stylesheet>
>
I just tried that, but am getting an error saying that "Error 3 Prefix 'dt' 
is not defined."

Thanks,

Tom
> -- 
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
date: Thu, 20 Mar 2008 16:34:48 -0700   author:   tshad

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us